From e1eefb8a8a25312754b64f7b74f76c0ee05cace7 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Thu, 28 Jun 2018 22:03:48 -0700 Subject: 4288 Give subx too the recent support for running a single test. --- subx/002test.cc | 20 +++++++++++++++++++- subx/build | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) 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 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 -- cgit 1.4.1-2-gfad0 ole.cc'>