about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--subx/002test.cc20
-rwxr-xr-xsubx/build1
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