aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/test_helpers.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_helpers.sh')
-rw-r--r--tests/test_helpers.sh16
1 files changed, 8 insertions, 8 deletions
diff --git a/tests/test_helpers.sh b/tests/test_helpers.sh
index 349dc3a..eaccd5c 100644
--- a/tests/test_helpers.sh
+++ b/tests/test_helpers.sh
@@ -1,19 +1,18 @@
function test_exit_code() {
- set +e
cat > main.c
"$ducc" -o a.out main.c
+ set +e
./a.out
exit_code=$?
+ set -e
expected=$1
if [[ $exit_code -ne $expected ]]; then
echo "invalid exit code: expected $expected, but got $exit_code" >&2
- set -e
exit 1
fi
- set -e
}
function test_diff() {
@@ -35,18 +34,19 @@ function test_diff() {
}
function test_compile_error() {
- set +e
cat > main.c
+ set +e
"$ducc" main.c > /dev/null 2> output
- if [[ $? -eq 0 ]]; then
- "expected to fail"
- set -e
+ exit_code=$?
+ set -e
+
+ if [[ $exit_code -eq 0 ]]; then
+ echo "expected to fail" >&2
exit 1
fi
diff -u expected output
- set -e
}
function test_example() {