From d943c45ec28202a453a8cc0a75ae175bf1305c1a Mon Sep 17 00:00:00 2001 From: "Ben L. Titzer" Date: Fri, 2 Feb 2024 10:27:08 -0500 Subject: [PATCH] [test/ci] Factor out parser and seman test invocation and make them fail fast --- test/common.bash | 27 +++++++++++++++++++++++++++ test/core/test.bash | 19 ++----------------- test/enums/test.bash | 19 ++----------------- test/float/test.bash | 18 ++---------------- test/fsi64/test.bash | 19 ++----------------- test/funcexpr/test.bash | 19 ++----------------- test/layout/test.bash | 19 ++----------------- test/range/test.bash | 20 ++------------------ test/variants/test.bash | 19 ++----------------- 9 files changed, 43 insertions(+), 136 deletions(-) diff --git a/test/common.bash b/test/common.bash index 59c41f4f6..d5f6ac05b 100755 --- a/test/common.bash +++ b/test/common.bash @@ -130,6 +130,33 @@ function check_no_red() { fi } +# Runs tests in ./parser/*.v3 +function do_parser_tests() { + cd parser + print_status Parser "" + run_v3c "" -test -expect=failures.txt *.v3 | tee $OUT/out | $PROGRESS + # TODO: accumulate errors and continue? + fail_fast + cd .. +} + +# Runs tests in ./seman/*.v3 +function do_seman_tests() { + cd seman + print_status Semantic "" + run_v3c "" -test -expect=failures.txt *.v3 | tee $OUT/out | $PROGRESS + # TODO: accumulate errors and continue? + fail_fast + cd .. +} + +function fail_fast() { + local code="$?" + if [ "$code" != 0 ]; then + exit $code + fi +} + function run_io_test() { target=$1 local runner=$2 diff --git a/test/core/test.bash b/test/core/test.bash index 9c5d0e5de..164b70c61 100755 --- a/test/core/test.bash +++ b/test/core/test.bash @@ -1,28 +1,13 @@ #!/bin/bash -function do_parser_tests() { - cd parser - print_status Parser "" - run_v3c "" -test -expect=failures.txt *.v3 | tee $OUT/out | $PROGRESS - cd .. -} - -function do_seman_tests() { - cd seman - print_status Semantic "" - run_v3c "" -test -expect=failures.txt *.v3 | tee $OUT/out | $PROGRESS - cd .. -} - . ../common.bash core if [ $# -gt 0 ]; then TESTS="$@" else - (do_parser_tests) - (do_seman_tests) + do_parser_tests + do_seman_tests TESTS=*.v3 fi execute_tests -exit $? diff --git a/test/enums/test.bash b/test/enums/test.bash index 3b6249269..201f482ff 100755 --- a/test/enums/test.bash +++ b/test/enums/test.bash @@ -1,28 +1,13 @@ #!/bin/bash -function do_parser_tests() { - cd parser - print_status Parser "" - run_v3c "" -test -expect=failures.txt *.v3 | tee $OUT/out | $PROGRESS - cd .. -} - -function do_seman_tests() { - cd seman - print_status Semantic "" - run_v3c "" -test -expect=failures.txt *.v3 | tee $OUT/out | $PROGRESS - cd .. -} - . ../common.bash enums if [ $# -gt 0 ]; then TESTS="$@" else - (do_parser_tests) - (do_seman_tests) + do_parser_tests + do_seman_tests TESTS=*.v3 fi execute_tests -exit $? diff --git a/test/float/test.bash b/test/float/test.bash index f9bb1a79d..2ee6b675f 100755 --- a/test/float/test.bash +++ b/test/float/test.bash @@ -1,25 +1,11 @@ #!/bin/bash -function do_parser_tests() { - cd parser - print_status Parser "" - run_v3c "" -test -expect=failures.txt *.v3 | tee $OUT/out | $PROGRESS - cd .. -} - -function do_seman_tests() { - cd seman - print_status Semantic "" - run_v3c "" -test -expect=failures.txt *.v3 | tee $OUT/out | $PROGRESS - cd .. -} - . ../common.bash float if [ $# -gt 0 ]; then TESTS="$@" else - (do_parser_tests) - (do_seman_tests) + do_parser_tests + do_seman_tests TESTS=*.v3 fi diff --git a/test/fsi64/test.bash b/test/fsi64/test.bash index 95b9c2289..39e0eae4e 100755 --- a/test/fsi64/test.bash +++ b/test/fsi64/test.bash @@ -1,28 +1,13 @@ #!/bin/bash -function do_parser_tests() { - cd parser - print_status Parser "" - run_v3c "" -test -expect=failures.txt *.v3 | tee $OUT/out | $PROGRESS - cd .. -} - -function do_seman_tests() { - cd seman - print_status Semantic "" - run_v3c "" -test -expect=failures.txt *.v3 | tee $OUT/out | $PROGRESS - cd .. -} - . ../common.bash fsi64 if [ $# -gt 0 ]; then TESTS="$@" else - (do_parser_tests) - (do_seman_tests) + do_parser_tests + do_seman_tests TESTS=*.v3 fi execute_tests -exit $? diff --git a/test/funcexpr/test.bash b/test/funcexpr/test.bash index 9716e1f68..9f6fe483e 100755 --- a/test/funcexpr/test.bash +++ b/test/funcexpr/test.bash @@ -1,28 +1,13 @@ #!/bin/bash -function do_parser_tests() { - cd parser - print_status Parser "" - run_v3c "" -test -expect=failures.txt *.v3 | tee $OUT/out | $PROGRESS - cd .. -} - -function do_seman_tests() { - cd seman - print_status Semantic "" - run_v3c "" -test -expect=failures.txt *.v3 | tee $OUT/out | $PROGRESS - cd .. -} - . ../common.bash funcexpr if [ $# -gt 0 ]; then TESTS="$@" else - (do_parser_tests) - (do_seman_tests) + do_parser_tests + do_seman_tests TESTS=*.v3 fi execute_tests -exit $? diff --git a/test/layout/test.bash b/test/layout/test.bash index f00c9d372..a870bd05e 100755 --- a/test/layout/test.bash +++ b/test/layout/test.bash @@ -1,28 +1,13 @@ #!/bin/bash -function do_parser_tests() { - cd parser - print_status Parser "" - run_v3c "" -test -expect=failures.txt *.v3 | tee $OUT/out | $PROGRESS - cd .. -} - -function do_seman_tests() { - cd seman - print_status Semantic "" - run_v3c "" -test -expect=failures.txt *.v3 | tee $OUT/out | $PROGRESS - cd .. -} - . ../common.bash layout if [ $# -gt 0 ]; then TESTS="$@" else - (do_parser_tests) - (do_seman_tests) + do_parser_tests + do_seman_tests TESTS=*.v3 fi execute_tests -exit $? diff --git a/test/range/test.bash b/test/range/test.bash index 7be567945..18c45a3ce 100755 --- a/test/range/test.bash +++ b/test/range/test.bash @@ -1,29 +1,13 @@ #!/bin/bash -function do_parser_tests() { - cd parser - print_status Parser "" - run_v3c "" -test -expect=failures.txt *.v3 | tee $OUT/out | $PROGRESS - cd .. -} - -function do_seman_tests() { - cd seman - print_status Semantic "" - run_v3c "" -test -expect=failures.txt *.v3 | tee $OUT/out | $PROGRESS - cd .. -} - . ../common.bash range if [ $# -gt 0 ]; then TESTS="$@" else - (do_parser_tests) - (do_seman_tests) + do_parser_tests + do_seman_tests TESTS=*.v3 fi execute_tests -exit $? - diff --git a/test/variants/test.bash b/test/variants/test.bash index 03ba00e49..afa6dd5b9 100755 --- a/test/variants/test.bash +++ b/test/variants/test.bash @@ -1,29 +1,14 @@ #!/bin/bash -function do_parser_tests() { - cd parser - print_status Parser "" - run_v3c "" -test -expect=failures.txt *.v3 | tee $OUT/out | $PROGRESS - cd .. -} - -function do_seman_tests() { - cd seman - print_status Semantic "" - run_v3c "" -test -expect=failures.txt *.v3 | tee $OUT/out | $PROGRESS - cd .. -} - . ../common.bash variants if [ $# -gt 0 ]; then TESTS="$@" else - (do_parser_tests) - (do_seman_tests) + do_parser_tests + do_seman_tests TESTS=*.v3 fi execute_tests -exit $?