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 /subx/002test.cc | |
parent | cd23c8b6fe2b7ce2f3771c0571b920404a4ce88e (diff) | |
download | mu-e1eefb8a8a25312754b64f7b74f76c0ee05cace7.tar.gz |
4288
Give subx too the recent support for running a single test.
Diffstat (limited to 'subx/002test.cc')
-rw-r--r-- | subx/002test.cc | 20 |
1 files changed, 19 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> |