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.
This commit is contained in:
Kartik Agaram 2018-07-25 12:24:00 -07:00
parent d7297b82c5
commit f898ee7a37
8 changed files with 18 additions and 1 deletions

1
build0
View File

@ -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

2
build1
View File

@ -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

2
build2
View File

@ -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
}

2
build3
View File

@ -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
}

2
build4
View File

@ -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"
}

View File

@ -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
}

View File

@ -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;

View File

@ -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])();