Skip to content

Commit

Permalink
[test/ci] Factor out parser and seman test invocation and make them f…
Browse files Browse the repository at this point in the history
…ail fast
  • Loading branch information
titzer committed Feb 2, 2024
1 parent d86a361 commit d943c45
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 136 deletions.
27 changes: 27 additions & 0 deletions test/common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 2 additions & 17 deletions test/core/test.bash
Original file line number Diff line number Diff line change
@@ -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 $?
19 changes: 2 additions & 17 deletions test/enums/test.bash
Original file line number Diff line number Diff line change
@@ -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 $?
18 changes: 2 additions & 16 deletions test/float/test.bash
Original file line number Diff line number Diff line change
@@ -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
Expand Down
19 changes: 2 additions & 17 deletions test/fsi64/test.bash
Original file line number Diff line number Diff line change
@@ -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 $?
19 changes: 2 additions & 17 deletions test/funcexpr/test.bash
Original file line number Diff line number Diff line change
@@ -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 $?
19 changes: 2 additions & 17 deletions test/layout/test.bash
Original file line number Diff line number Diff line change
@@ -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 $?
20 changes: 2 additions & 18 deletions test/range/test.bash
Original file line number Diff line number Diff line change
@@ -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 $?

19 changes: 2 additions & 17 deletions test/variants/test.bash
Original file line number Diff line number Diff line change
@@ -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 $?

0 comments on commit d943c45

Please sign in to comment.