about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-06-06 09:02:40 -0700
committerKartik Agaram <vc@akkartik.com>2018-06-06 09:27:44 -0700
commit53172ce13ab2add6c0000ee11c32e874df67b86e (patch)
tree961b38bdef770a324f8a35ceed1f0f183f8f5446
parent8f97725d0088d86ae157006234d1d0009b1dbf4c (diff)
downloadmu-53172ce13ab2add6c0000ee11c32e874df67b86e.tar.gz
4253 - support running just a single C test
We've had this ability for Mu scenarios forever.
-rw-r--r--002test.cc16
-rwxr-xr-xbuild01
-rwxr-xr-xbuild11
-rwxr-xr-xbuild21
-rwxr-xr-xbuild31
-rwxr-xr-xbuild41
-rwxr-xr-xbuild_and_test_until4
7 files changed, 24 insertions, 1 deletions
diff --git a/002test.cc b/002test.cc
index b47731b5..9b39b311 100644
--- a/002test.cc
+++ b/002test.cc
@@ -15,6 +15,9 @@ typedef void (*test_fn)(void);
 const test_fn Tests[] = {
   #include "test_list"  // auto-generated; see 'build*' scripts
 };
+const string Test_names[] = {
+  #include "test_name_list"
+};
 
 :(before "End Globals")
 bool Run_tests = false;
@@ -82,5 +85,18 @@ void run_test(size_t i) {
   // End Test Teardown
 }
 
+//: Convenience: run a single test
+:(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/build0 b/build0
index 7cc6fc95..b31b8bd0 100755
--- a/build0
+++ b/build0
@@ -38,6 +38,7 @@ cd ..
 grep -h "^[^[:space:]#].*) {$" mu.cc  |grep -v ":.*("  |sed 's/ {.*/;/'  > function_list
 # auto-generate list of tests to run
 grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/\1,/'  > test_list
+grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  > test_name_list
 g++ -g -O2 mu.cc termbox/libtermbox.a -o mu_bin
 
 cat [0-9]*.mu > core.mu
diff --git a/build1 b/build1
index f138fa15..dbb58cfd 100755
--- a/build1
+++ b/build1
@@ -57,6 +57,7 @@ LAYERS=$(./enumerate/enumerate --until $UNTIL_LAYER  |grep '\.cc$')
 grep -h "^[^[:space:]#].*) {$" mu.cc  |grep -v ":.*("  |sed 's/ {.*/;/'  > function_list
 # auto-generate list of tests to run
 grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/\1,/'  > test_list
+grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  > test_name_list
 $CXX $CFLAGS mu.cc termbox/libtermbox.a -o mu_bin
 
 ## [0-9]*.mu -> core.mu
diff --git a/build2 b/build2
index 2d4703df..80c9c820 100755
--- a/build2
+++ b/build2
@@ -125,6 +125,7 @@ mkdir -p .build
 grep -h "^[^[:space:]#].*) {$" mu.cc  |grep -v ":.*("  |sed 's/ {.*/;/'  |update .build/function_list
 # auto-generate list of tests to run
 grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/\1,/'  |update .build/test_list
+grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  |update .build/test_name_list
 mkdir -p .build/termbox
 update_cp termbox/termbox.h .build/termbox
 
diff --git a/build3 b/build3
index 0d997f6f..09c7398d 100755
--- a/build3
+++ b/build3
@@ -150,6 +150,7 @@ mkdir -p .build
 grep -h "^[^[:space:]#].*) {$" mu.cc  |grep -v ":.*("  |sed 's/ {.*/;/'  |update .build/function_list
 # auto-generate list of tests to run
 grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/\1,/'  |update .build/test_list
+grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  |update .build/test_name_list
 mkdir -p .build/termbox
 update_cp termbox/termbox.h .build/termbox
 
diff --git a/build4 b/build4
index 132d9138..66b7a74c 100755
--- a/build4
+++ b/build4
@@ -193,6 +193,7 @@ mkdir -p .build
 grep -h "^[^[:space:]#].*) {$" mu.cc  |grep -v ":.*("  |sed 's/ {.*/;/'  |update .build/function_list
 # auto-generate list of tests to run
 grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/\1,/'  |update .build/test_list
+grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  |update .build/test_name_list
 mkdir -p .build/termbox
 update_cp termbox/termbox.h .build/termbox
 
diff --git a/build_and_test_until b/build_and_test_until
index 6959a9fb..ed560e36 100755
--- a/build_and_test_until
+++ b/build_and_test_until
@@ -1,7 +1,9 @@
 #!/bin/sh
+# Run tests for just a subset of layers.
+#
 # Usage:
 #   build_and_test_until [file prefix] [test name]
-# Provide the second arg to run just a single (Mu) scenario.
+# Provide the second arg to run just a single test.
 set -e
 
 # clean previous builds if they were building until a different layer