about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-07-25 12:24:00 -0700
committerKartik Agaram <vc@akkartik.com>2018-07-25 13:07:01 -0700
commitf898ee7a374c20f58150158a5066f547060d9c24 (patch)
tree2660867079b0a36f4b4a27bfec1d5dd00cc1f521
parentd7297b82c57b7920d6cff9c22e87afe77451a786 (diff)
downloadmu-f898ee7a374c20f58150158a5066f547060d9c24.tar.gz
4403
Couple of improvements for the tangle/ directory:
  a) Start running tangle unit tests at build time again.
  b) Option to print out test names as they run, just like in top-level.
-rwxr-xr-xbuild01
-rwxr-xr-xbuild12
-rwxr-xr-xbuild22
-rwxr-xr-xbuild32
-rwxr-xr-xbuild42
-rwxr-xr-xsubx/build2
-rw-r--r--tangle/000test.cc7
-rw-r--r--tangle/002main.cc1
8 files changed, 18 insertions, 1 deletions
diff --git a/build0 b/build0
index b31b8bd0..7c2f1da1 100755
--- a/build0
+++ b/build0
@@ -22,6 +22,7 @@ cd tangle
   # }
   # Now that we have all the _lists, compile 'tangle'
   g++ -g -O2 boot.cc -o tangle
+  ./tangle test
 cd ..
 
 cd termbox
diff --git a/build1 b/build1
index dbb58cfd..2551cfeb 100755
--- a/build1
+++ b/build1
@@ -37,9 +37,11 @@ cd tangle
   ls [0-9]*.test.cc  |sed 's/.*/#include "&"/'  > test_file_list
   # list of tests to run
   grep -h "^[[:space:]]*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {$/\1,/'  > test_list
+  grep -h "^\s*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  > test_name_list
   # }
   # Now that we have all the _lists, compile 'tangle'
   $CXX $CFLAGS boot.cc -o tangle
+  ./tangle test
 cd ..
 
 cd termbox
diff --git a/build2 b/build2
index 80c9c820..fd065f08 100755
--- a/build2
+++ b/build2
@@ -100,9 +100,11 @@ older_than tangle/tangle tangle/*.cc && {
     ls [0-9]*.test.cc  |sed 's/.*/#include "&"/'  |update test_file_list
     # list of tests to run
     grep -h "^[[:space:]]*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {$/\1,/'  |update test_list
+    grep -h "^\s*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  |update test_name_list
     # }
     # Now that we have all the _lists, compile 'tangle'
     $CXX $CFLAGS boot.cc -o tangle
+    ./tangle test
   noisy_cd ..  # no effect; just to show us returning to the parent directory
 }
 
diff --git a/build3 b/build3
index 09c7398d..db251087 100755
--- a/build3
+++ b/build3
@@ -125,9 +125,11 @@ older_than tangle/tangle tangle/*.cc && {
     ls [0-9]*.test.cc  |sed 's/.*/#include "&"/'  |update test_file_list
     # list of tests to run
     grep -h "^[[:space:]]*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {$/\1,/'  |update test_list
+    grep -h "^\s*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  |update test_name_list
     # }
     # Now that we have all the _lists, compile 'tangle'
     $CXX $CFLAGS boot.cc -o tangle
+    ./tangle test
   noisy_cd ..  # no effect; just to show us returning to the parent directory
 }
 
diff --git a/build4 b/build4
index d31dc455..ab5c4a0b 100755
--- a/build4
+++ b/build4
@@ -156,9 +156,11 @@ mv_if_exists tangle/tangle $TMP
       ls [0-9]*.test.cc  |sed 's/.*/#include "&"/'  |update test_file_list
       # list of tests to run
       grep -h "^[[:space:]]*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {$/\1,/'  |update test_list
+      grep -h "^\s*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  |update test_name_list
       # }
       # Now that we have all the _lists, compile 'tangle'
       $CXX $CFLAGS boot.cc -o $TMP  ||  quit
+      $TMP test
     cd ..
     echo "done building tangle"
   }
diff --git a/subx/build b/subx/build
index 3bcbfc0c..1979d623 100755
--- a/subx/build
+++ b/subx/build
@@ -86,7 +86,9 @@ older_than ../tangle/tangle ../tangle/*.cc && {
     ls [0-9]*.cc  |grep -v "\.test\.cc$"  |sed 's/.*/#include "&"/'  |update file_list
     ls [0-9]*.test.cc  |sed 's/.*/#include "&"/'  |update test_file_list
     grep -h "^[[:space:]]*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {$/\1,/'  |update test_list
+    grep -h "^\s*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  |update test_name_list
     $CXX $CFLAGS boot.cc -o tangle
+    ./tangle test
   noisy_cd ../subx  # no effect; just to show us returning to the parent directory
 }
 
diff --git a/tangle/000test.cc b/tangle/000test.cc
index 2754b254..64551646 100644
--- a/tangle/000test.cc
+++ b/tangle/000test.cc
@@ -1,7 +1,12 @@
 typedef void (*test_fn)(void);
 
 const test_fn Tests[] = {
-  #include "test_list"  // auto-generated; see makefile
+  #include "test_list"  // auto-generated; see 'build*' scripts
+};
+
+// Names for each element of the 'Tests' global, respectively.
+const string Test_names[] = {
+  #include "test_name_list"  // auto-generated; see 'build*' scripts
 };
 
 bool Passed = true;
diff --git a/tangle/002main.cc b/tangle/002main.cc
index c8c61039..4529c463 100644
--- a/tangle/002main.cc
+++ b/tangle/002main.cc
@@ -22,6 +22,7 @@ string flag_value(const string& flag, int argc, const char* argv[]) {
 
 int run_tests() {
   for (unsigned long i=0; i < sizeof(Tests)/sizeof(Tests[0]); ++i) {
+//?     cerr << "running " << Test_names[i] << '\n';
     START_TRACING_UNTIL_END_OF_SCOPE;
     setup();
     (*Tests[i])();