Skip to content

Commit b6613f6

Browse files
committed
Run all test programs even if some fail.
1 parent 318643d commit b6613f6

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

integration_tests.sh

+32-15
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,22 @@ WHITE=$(tput setaf 7)
1212
BOLD=$(tput bold)
1313
RESET=$(tput sgr0)
1414

15-
# Die on first error.
16-
set -e
17-
1815
function summary {
1916
echo -e "$BOLD$GREEN==>$WHITE ${1}$RESET"
2017
}
2118

19+
failed=0
20+
2221
function compile_and_run {
2322
local test_program=$1
24-
summary "Testing $test_program"
2523

2624
# Compile the file.
2725
./target/release/bfc sample_programs/$test_program
26+
if [[ $? -ne 0 ]]; then
27+
echo "Compilation failed!"
28+
failed=1
29+
return
30+
fi
2831

2932
# Run it, saving output.
3033
local executable="${test_program%.*}"
@@ -35,23 +38,37 @@ function compile_and_run {
3538
else
3639
./$executable > output.txt
3740
fi
41+
if [[ $? -ne 0 ]]; then
42+
echo "Program crashed!"
43+
failed=1
44+
return
45+
fi
3846

3947
# Compare output.
4048
local expected_output=sample_programs/${test_program}.out
4149
if [ -f $expected_output ]; then
42-
echo -n " (checked output)"
43-
diff output.txt $expected_output
50+
diff output.txt $expected_output > /dev/null
51+
if [[ $? -ne 0 ]]; then
52+
echo "Output differs!"
53+
failed=1
54+
return
55+
fi
4456
fi
57+
}
4558

46-
# Cleanup.
47-
rm $executable output.txt
59+
function check_program {
60+
summary "Testing $1"
61+
compile_and_run $1
4862

49-
echo
63+
# Cleanup.
64+
rm -f ${1%.*} output.txt
5065
}
5166

52-
compile_and_run bangbang.bf
53-
compile_and_run hello_world.bf
54-
compile_and_run bottles.bf
55-
compile_and_run factor.bf
56-
compile_and_run mandelbrot.bf
57-
compile_and_run life.bf
67+
check_program bangbang.bf
68+
check_program hello_world.bf
69+
check_program bottles.bf
70+
check_program factor.bf
71+
check_program mandelbrot.bf
72+
check_program life.bf
73+
74+
exit $failed

0 commit comments

Comments
 (0)