hurl/integration/run.sh

60 lines
1.3 KiB
Bash
Raw Normal View History

2020-08-27 10:07:46 +03:00
#!/bin/bash
set -u
set -e
for hurl_file in "$@"; do
set +e
options=("")
if test -f "${hurl_file%.*}.options"; then
options+=("$(cat "${hurl_file%.*}.options")")
fi
2020-09-19 19:09:30 +03:00
cmd="hurl $hurl_file ${options[*]}"
echo "$cmd"
$cmd 2>/tmp/test.stderr >/tmp/test.stdout
2020-08-27 10:07:46 +03:00
EXITCODE_ACTUAL=$?
set -e
EXITCODE_EXPECTED=$(cat "${hurl_file%.*}.exit")
if [ "$EXITCODE_ACTUAL" != "$EXITCODE_EXPECTED" ]; then
echo "ERROR Exit Code"
echo " Expected: $EXITCODE_EXPECTED"
echo " Actual: $EXITCODE_ACTUAL"
# log unexpected error
if [ "$EXITCODE_ACTUAL" != 0 ]; then
cat /tmp/test.stderr
fi
exit 1
fi
if [ "$EXITCODE_ACTUAL" == 0 ]; then
expected=$(cat "${hurl_file%.*}.out")
actual=$(cat /tmp/test.stdout)
if [ "$actual" != "$expected" ]; then
diff <(echo "$actual" ) <(echo "$expected")
exit 1
fi
else
STDERR_EXPECTED=$(cat "${hurl_file%.*}.err")
STDERR_ACTUAL=$(cat /tmp/test.stderr)
if [ "$STDERR_ACTUAL" != "$STDERR_EXPECTED" ]; then
echo "ERROR StandardError"
echo " Expected: $STDERR_EXPECTED"
echo " Actual: $STDERR_ACTUAL"
exit 1
fi
fi
done