From e50fbff2d1ab98bd0fe8a16dfef8c7d38cba2563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Sun, 3 Dec 2017 21:46:03 +0100 Subject: [PATCH] Handle compilation errors of tests --- src/kernel/include/ttest.h | 2 +- ttest | 31 +++++++++++++++++++------------ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/kernel/include/ttest.h b/src/kernel/include/ttest.h index 08af4e8..c101a0b 100644 --- a/src/kernel/include/ttest.h +++ b/src/kernel/include/ttest.h @@ -116,7 +116,7 @@ int main(int argc, char **argv) } printf("\n"); - printf("%s----------------------------------------%s\n", TT_CLR_BLU, TT_CLR_RES); + /* printf("%s----------------------------------------%s\n", TT_CLR_BLU, TT_CLR_RES); */ printf("Ran %d tests in %s\n", i, tt_filename); free(buffer); if(failures) diff --git a/ttest b/ttest index 40907e3..cc229df 100755 --- a/ttest +++ b/ttest @@ -1,28 +1,35 @@ #!/bin/sh -set -e - dirs=src/kernel main() { - failed=0 + local failures=0 for dir in $dirs; do local files=`find $dir -name "*.tt"` - for f in $files; do + for suite in $files; do - cp $f $f.c - tests=`sed -n -e 's/^\s*TEST(\([^,]*,\).*$/ttt_\1/p' $f` - echo "tt_test tt_tests[] = {${tests}0};" >> $f.c + cp $suite $suite.c + local tests=`sed -n -e 's/^\s*TEST(\([^,]*,\).*$/ttt_\1/p' $suite` + echo "tt_test tt_tests[] = {${tests}0};" >> $suite.c - outfile=`mktemp` - cc $f.c -o $outfile -ggdb -I $dir/include 2>&1 | sed -e 's/\.tt\.c:/\.tt:/' - $outfile $f || failed=1 - rm $f.c $outfile + test_exec=`mktemp` + compiler_output=`cc $suite.c -o $test_exec -ggdb -I $dir/include 2>&1` + compiler_status=$? + + echo -e "\x1b[35m$suite\x1b[0m" + if [[ "$compiler_status" -eq "0" ]]; then + $test_exec $suite || failures=$(($failures + 1)) + else + failures=$(($failures + 1)) + echo -e "\x1b[31mCOMPILATION OF SUITE FAILED\x1b[0m" + echo "$compiler_output" | sed -e 's/\.tt\.c:/\.tt:/' + fi + rm -f $suite.c $test_exec done done - exit $failed + exit $failures }