Skip to content

Commit

Permalink
Added option to selectively test via gtools, test[]
Browse files Browse the repository at this point in the history
  • Loading branch information
mcaceresb committed Aug 19, 2018
1 parent 0fe7a65 commit 8d8e928
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 23 deletions.
50 changes: 40 additions & 10 deletions build/gtools.ado
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
}
}
Expand Down Expand Up @@ -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
}
}
Expand All @@ -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
}
}
Expand Down Expand Up @@ -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 {
Expand Down
19 changes: 18 additions & 1 deletion build/gtools.sthlp
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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}

Expand Down
19 changes: 18 additions & 1 deletion docs/stata/gtools.sthlp
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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}

Expand Down
12 changes: 11 additions & 1 deletion docs/usage/gtools.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
50 changes: 40 additions & 10 deletions src/ado/gtools.ado
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
}
}
Expand Down Expand Up @@ -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
}
}
Expand All @@ -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
}
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 8d8e928

Please sign in to comment.