From 8d8e928c3553044f1b97eb72ebed8c6b1f9c0e41 Mon Sep 17 00:00:00 2001 From: Mauricio Caceres Date: Sun, 19 Aug 2018 13:46:45 -0400 Subject: [PATCH] Added option to selectively test via gtools, test[] --- build/gtools.ado | 50 ++++++++++++++++++++++++++++++++--------- build/gtools.sthlp | 19 +++++++++++++++- docs/stata/gtools.sthlp | 19 +++++++++++++++- docs/usage/gtools.md | 12 +++++++++- src/ado/gtools.ado | 50 ++++++++++++++++++++++++++++++++--------- 5 files changed, 127 insertions(+), 23 deletions(-) diff --git a/build/gtools.ado b/build/gtools.ado index 029b9c19..50cea81e 100644 --- a/build/gtools.ado +++ b/build/gtools.ado @@ -20,10 +20,15 @@ program gtools showcase /// examples /// test /// + TESTs(str) /// branch(str) /// ] - if ( "`branch'" == "" ) local branch master + if ( `"`branch'"' == "" ) local branch master + if !inlist(`"`branch'"', "develop", "master", "osx") { + disp as err "unknown branch `branch'; available: develop master osx" + exit 198 + } local cwd `c(pwd)' local github https://raw.githubusercontent.com/mcaceresb/stata-gtools/`branch' @@ -41,7 +46,7 @@ program gtools gtools_licenses } - if ( `"`dependencies'`hashlib'`install_latest'`upgrade'`dll'`showcase'`examples'`test'"' == `""' ) { + if ( `"`dependencies'`hashlib'`install_latest'`upgrade'`dll'`showcase'`examples'`test'`tests'"' == `""' ) { exit 0 } } @@ -83,7 +88,7 @@ program gtools di as txt "Success!" cd `"`cwd'"' - if ( `"`hashlib'`install_latest'`upgrade'`dll'`showcase'`examples'`test'"' == `""' ) { + if ( `"`hashlib'`install_latest'`upgrade'`dll'`showcase'`examples'`test'`tests'"' == `""' ) { exit 0 } } @@ -92,7 +97,7 @@ program gtools cap net uninstall gtools net install gtools, from(`github'/build) replace * gtools, dependencies replace - if ( `"`hashlib'`dll'`showcase'`examples'`test'"' == `""' ) { + if ( `"`hashlib'`dll'`showcase'`examples'`test'`tests'"' == `""' ) { exit 0 } } @@ -155,30 +160,55 @@ program gtools } } else local hashlib spookyhash.dll - if ( `"`showcase'`examples'`test'"' == `""' ) { + if ( `"`showcase'`examples'`test'`tests'"' == `""' ) { exit 0 } } else if ( `hashusr' | ("`dll'" == "dll") ) { di as txt "-gtools, hashlib()- and -gtools, dll- only on Windows." - if ( `"`showcase'`examples'`test'"' == `""' ) { + if ( `"`showcase'`examples'`test'`tests'"' == `""' ) { exit 0 } } if ( "`showcase'`examples'" != "" ) { gtools_showcase - if ( "`test'" == "" ) { + if ( "`test'`tests'" == "" ) { exit 0 } } - if ( "`test'" != "" ) { - disp as txt "{bf:WARNING:} Unit tests from branch `branch' take 1-3 hours!" + if ( "`test'`tests'" != "" ) { + local t_hours comparisons + local t_days bench_full + local t_known dependencies basic_checks comparisons switches bench_test bench_full + local t_extra: list tests - t_known + + if ( `:list sizeof t_extra' ) { + disp `"(uknown tests detected: `t_extra'; will try to run anyway)"' + } + + if ( "`tests'" == "" ) { + disp as txt "{bf:WARNING:} Default unit tests from branch `branch' can take several" + disp as txt "hours. See {help gtools:help gtools} for details on unit testing." + } + else if ( `:list t_hours in tests' ) { + disp as txt "{bf:WARNING:} Unit tests" + disp as txt _n(1) " `tests'" _n(1) + disp as txt "from branch master can take several hours. See {help gtools:help gtools} for details." + } + else if ( `:list t_days in tests' ) { + disp as txt "{bf:WARNING:} Unit tests" + disp as txt _n(1) " `tests'" _n(1) + disp as txt "from branch master can take more than a day. See {help gtools:help gtools} for details." + } + else { + disp as txt "{bf:Note:} Unit tests '`tests'' from branch `branch'." + } disp as txt "Are you sure you want to run them? (yes/no)", _request(GTOOLS_TESTS) if inlist(`"${GTOOLS_TESTS}"', "y", "yes") { global GTOOLS_TESTS - cap noi do `github'/build/gtools_tests.do + cap noi do `github'/build/gtools_tests.do `tests' exit _rc } else { diff --git a/build/gtools.sthlp b/build/gtools.sthlp index e6a91cdd..95e5e3e8 100644 --- a/build/gtools.sthlp +++ b/build/gtools.sthlp @@ -82,7 +82,7 @@ traditional stata commands. The following are available as part of gtools {p_end} {synopt :{opt showcase}}Alias for {opt examples}. {p_end} -{synopt :{opt test}}Run gtools unit tests (1-3h) from the specified github branch (default is master). +{synopt :{opt test[(tests)]}}Run unit tests, optionally specifying which tests to run. {p_end} {synopt :{opth branch(str)}}Github branch to use (defualt is master). {p_end} @@ -138,6 +138,23 @@ is required for the plugin to execute correctly. {opt examples} (alias {opt showcase}) prints examples of how to use various gtools functions. +{phang} + +{opt test[(tests)]} Run unit tests, optionally specifying which tests +to run. Tests available are: dependencies, basic_checks, bench_test, +comparisons, switches, bench_full. A good set of "small" tests which +take 10-20 minutes are {cmd: dependencies basic_checks bench_test}. +By default, however, the first 5 tests are run, which take 1-3h. The +bulk of that time is from {bf:comparisons}, which compares the results +from gtools to that of various native counterparts under several +different conditions. {bf:bench_full} is not run by default because this +benchmarks gtools against stata using modestly-sized data (millions). +Some stata commands are very slow under some of the benchmarks, meaning +this can take well over a day. + +{phang} +{opth branch(str)} Github branch to use (defualt is master). + {marker author}{...} {title:Author} diff --git a/docs/stata/gtools.sthlp b/docs/stata/gtools.sthlp index e6a91cdd..95e5e3e8 100644 --- a/docs/stata/gtools.sthlp +++ b/docs/stata/gtools.sthlp @@ -82,7 +82,7 @@ traditional stata commands. The following are available as part of gtools {p_end} {synopt :{opt showcase}}Alias for {opt examples}. {p_end} -{synopt :{opt test}}Run gtools unit tests (1-3h) from the specified github branch (default is master). +{synopt :{opt test[(tests)]}}Run unit tests, optionally specifying which tests to run. {p_end} {synopt :{opth branch(str)}}Github branch to use (defualt is master). {p_end} @@ -138,6 +138,23 @@ is required for the plugin to execute correctly. {opt examples} (alias {opt showcase}) prints examples of how to use various gtools functions. +{phang} + +{opt test[(tests)]} Run unit tests, optionally specifying which tests +to run. Tests available are: dependencies, basic_checks, bench_test, +comparisons, switches, bench_full. A good set of "small" tests which +take 10-20 minutes are {cmd: dependencies basic_checks bench_test}. +By default, however, the first 5 tests are run, which take 1-3h. The +bulk of that time is from {bf:comparisons}, which compares the results +from gtools to that of various native counterparts under several +different conditions. {bf:bench_full} is not run by default because this +benchmarks gtools against stata using modestly-sized data (millions). +Some stata commands are very slow under some of the benchmarks, meaning +this can take well over a day. + +{phang} +{opth branch(str)} Github branch to use (defualt is master). + {marker author}{...} {title:Author} diff --git a/docs/usage/gtools.md b/docs/usage/gtools.md index 3de530ec..f9e98607 100644 --- a/docs/usage/gtools.md +++ b/docs/usage/gtools.md @@ -48,6 +48,16 @@ Options - `examples` (alias `showcase`) Print examples of how to use available gtools functions. -- `test` Runs the gtools unit tests (1-3h) from the specified github branch (default is master). +- `test[(str)]` Run unit tests, optionally specifying which tests to run. Tests + available are: `dependencies`, `basic_checks`, `bench_test`, + `comparisons`, `switches`, `bench_full`. A good set of "small" tests + which take 10-20 minutes are `dependencies basic_checks bench_test`. By + default, however, the first 5 tests are run, which take 1-3h. The bulk + of that time is from `comparisons`, which compares the results from + gtools to that of various native counterparts under several different + conditions. `bench_full` is not run by default because this benchmarks + gtools against stata using modestly-sized data (millions). Some stata + commands are very slow under some of the benchmarks, meaning this can + take well over a day. - `branch(str)` Github branch to use (default is master). diff --git a/src/ado/gtools.ado b/src/ado/gtools.ado index 029b9c19..50cea81e 100644 --- a/src/ado/gtools.ado +++ b/src/ado/gtools.ado @@ -20,10 +20,15 @@ program gtools showcase /// examples /// test /// + TESTs(str) /// branch(str) /// ] - if ( "`branch'" == "" ) local branch master + if ( `"`branch'"' == "" ) local branch master + if !inlist(`"`branch'"', "develop", "master", "osx") { + disp as err "unknown branch `branch'; available: develop master osx" + exit 198 + } local cwd `c(pwd)' local github https://raw.githubusercontent.com/mcaceresb/stata-gtools/`branch' @@ -41,7 +46,7 @@ program gtools gtools_licenses } - if ( `"`dependencies'`hashlib'`install_latest'`upgrade'`dll'`showcase'`examples'`test'"' == `""' ) { + if ( `"`dependencies'`hashlib'`install_latest'`upgrade'`dll'`showcase'`examples'`test'`tests'"' == `""' ) { exit 0 } } @@ -83,7 +88,7 @@ program gtools di as txt "Success!" cd `"`cwd'"' - if ( `"`hashlib'`install_latest'`upgrade'`dll'`showcase'`examples'`test'"' == `""' ) { + if ( `"`hashlib'`install_latest'`upgrade'`dll'`showcase'`examples'`test'`tests'"' == `""' ) { exit 0 } } @@ -92,7 +97,7 @@ program gtools cap net uninstall gtools net install gtools, from(`github'/build) replace * gtools, dependencies replace - if ( `"`hashlib'`dll'`showcase'`examples'`test'"' == `""' ) { + if ( `"`hashlib'`dll'`showcase'`examples'`test'`tests'"' == `""' ) { exit 0 } } @@ -155,30 +160,55 @@ program gtools } } else local hashlib spookyhash.dll - if ( `"`showcase'`examples'`test'"' == `""' ) { + if ( `"`showcase'`examples'`test'`tests'"' == `""' ) { exit 0 } } else if ( `hashusr' | ("`dll'" == "dll") ) { di as txt "-gtools, hashlib()- and -gtools, dll- only on Windows." - if ( `"`showcase'`examples'`test'"' == `""' ) { + if ( `"`showcase'`examples'`test'`tests'"' == `""' ) { exit 0 } } if ( "`showcase'`examples'" != "" ) { gtools_showcase - if ( "`test'" == "" ) { + if ( "`test'`tests'" == "" ) { exit 0 } } - if ( "`test'" != "" ) { - disp as txt "{bf:WARNING:} Unit tests from branch `branch' take 1-3 hours!" + if ( "`test'`tests'" != "" ) { + local t_hours comparisons + local t_days bench_full + local t_known dependencies basic_checks comparisons switches bench_test bench_full + local t_extra: list tests - t_known + + if ( `:list sizeof t_extra' ) { + disp `"(uknown tests detected: `t_extra'; will try to run anyway)"' + } + + if ( "`tests'" == "" ) { + disp as txt "{bf:WARNING:} Default unit tests from branch `branch' can take several" + disp as txt "hours. See {help gtools:help gtools} for details on unit testing." + } + else if ( `:list t_hours in tests' ) { + disp as txt "{bf:WARNING:} Unit tests" + disp as txt _n(1) " `tests'" _n(1) + disp as txt "from branch master can take several hours. See {help gtools:help gtools} for details." + } + else if ( `:list t_days in tests' ) { + disp as txt "{bf:WARNING:} Unit tests" + disp as txt _n(1) " `tests'" _n(1) + disp as txt "from branch master can take more than a day. See {help gtools:help gtools} for details." + } + else { + disp as txt "{bf:Note:} Unit tests '`tests'' from branch `branch'." + } disp as txt "Are you sure you want to run them? (yes/no)", _request(GTOOLS_TESTS) if inlist(`"${GTOOLS_TESTS}"', "y", "yes") { global GTOOLS_TESTS - cap noi do `github'/build/gtools_tests.do + cap noi do `github'/build/gtools_tests.do `tests' exit _rc } else {