diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-06-28 22:03:48 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-06-28 22:03:48 -0700 |
commit | e1eefb8a8a25312754b64f7b74f76c0ee05cace7 (patch) | |
tree | a121d842bdca82e23972ca9c916e3fafaa5d943c | |
parent | cd23c8b6fe2b7ce2f3771c0571b920404a4ce88e (diff) | |
download | mu-e1eefb8a8a25312754b64f7b74f76c0ee05cace7.tar.gz |
4288
Give subx too the recent support for running a single test.
-rw-r--r-- | subx/002test.cc | 20 | ||||
-rwxr-xr-x | subx/build | 1 |
2 files changed, 20 insertions, 1 deletions
diff --git a/subx/002test.cc b/subx/002test.cc index 33560a9d..af6c34a3 100644 --- a/subx/002test.cc +++ b/subx/002test.cc @@ -54,7 +54,7 @@ if (Run_tests) { time_t t; time(&t); cerr << "C tests: " << ctime(&t); for (size_t i=0; i < sizeof(Tests)/sizeof(Tests[0]); ++i) { -//? cerr << "running .build/test_list line " << (i+1) << '\n'; +//? cerr << "running " << Test_names[i] << '\n'; run_test(i); if (Passed) cerr << '.'; else ++num_failures; @@ -82,5 +82,23 @@ void run_test(size_t i) { // End Test Teardown } +//: Convenience: run a single test +:(before "Globals") +// Names for each element of the 'Tests' global, respectively. +const string Test_names[] = { + #include "test_name_list" // auto-generated; see 'build*' scripts +}; +:(after "Test Runs") +string maybe_single_test_to_run = argv[argc-1]; +if (!starts_with(maybe_single_test_to_run, "test_")) + maybe_single_test_to_run.insert(0, "test_"); +for (size_t i=0; i < sizeof(Tests)/sizeof(Tests[0]); ++i) { + if (Test_names[i] == maybe_single_test_to_run) { + run_test(i); + if (Passed) cerr << ".\n"; + return 0; + } +} + :(before "End Includes") #include <stdlib.h> diff --git a/subx/build b/subx/build index 7d01f975..3bcbfc0c 100755 --- a/subx/build +++ b/subx/build @@ -98,6 +98,7 @@ older_than subx.cc $LAYERS ../enumerate/enumerate ../tangle/tangle && { grep -h "^[^[:space:]#].*) {$" subx.cc |grep -v ":.*(" |sed 's/ {.*/;/' |update function_list grep -h "^\s*void test_" subx.cc |sed 's/^\s*void \(.*\)() {.*/\1,/' |update test_list +grep -h "^\s*void test_" subx.cc |sed 's/^\s*void \(.*\)() {.*/"\1",/' |update test_name_list older_than subx_bin subx.cc *_list && { $CXX $CFLAGS subx.cc -o subx_bin |