2022-04-28 23:28:45 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Arg 1: qb54 location
|
|
|
|
|
|
|
|
PREFIX="Compilation"
|
|
|
|
|
|
|
|
RESULTS_DIR="./tests/results/$PREFIX"
|
|
|
|
|
|
|
|
mkdir -p $RESULTS_DIR
|
|
|
|
|
|
|
|
QB64=$1
|
|
|
|
|
|
|
|
show_failure()
|
|
|
|
{
|
|
|
|
cat "$RESULTS_DIR/$1-compile_result.txt"
|
|
|
|
cat "$RESULTS_DIR/$1-compilelog.txt"
|
|
|
|
}
|
|
|
|
|
2022-05-09 03:02:21 +00:00
|
|
|
show_incorrect_result()
|
|
|
|
{
|
|
|
|
printf "EXPECTED: '%s'\n" "$1"
|
|
|
|
printf "GOT: '%s'\n" "$2"
|
|
|
|
}
|
|
|
|
|
2022-05-23 03:54:20 +00:00
|
|
|
for test in ./tests/compile_tests/*
|
2022-04-28 23:28:45 +00:00
|
|
|
do
|
2022-05-23 03:54:20 +00:00
|
|
|
test=$(basename "$test")
|
|
|
|
|
|
|
|
TESTCASE="$test"
|
|
|
|
EXE="$RESULTS_DIR/$test - output"
|
2022-04-28 23:28:45 +00:00
|
|
|
|
2022-05-11 00:11:51 +00:00
|
|
|
# Clear out temp folder before next compile, avoids stale compilelog files
|
|
|
|
rm -fr ./internal/temp/*
|
|
|
|
|
2022-05-23 03:54:20 +00:00
|
|
|
"$QB64" -x "./tests/compile_tests/$test/test.bas" -o "$EXE" 1>"$RESULTS_DIR/$test-compile_result.txt"
|
2022-04-28 23:28:45 +00:00
|
|
|
ERR=$?
|
2022-05-23 03:54:20 +00:00
|
|
|
cp_if_exists ./internal/temp/compilelog.txt "$RESULTS_DIR/$test-compilelog.txt"
|
2022-04-28 23:28:45 +00:00
|
|
|
|
|
|
|
(exit $ERR)
|
2022-05-23 03:54:20 +00:00
|
|
|
assert_success_named "Compile" "Compilation Error:" show_failure "$test"
|
2022-05-09 03:02:21 +00:00
|
|
|
|
|
|
|
test -f "$EXE"
|
2022-05-23 03:54:20 +00:00
|
|
|
assert_success_named "exe exists" "$test-output executable does not exist!" show_failure "$test"
|
2022-05-09 03:02:21 +00:00
|
|
|
|
|
|
|
if [ ! -f "./tests/compile_tests/$test/test.output" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2022-05-23 03:54:20 +00:00
|
|
|
expectedResult="$(cat "./tests/compile_tests/$test/test.output")"
|
2022-05-09 03:02:21 +00:00
|
|
|
|
|
|
|
pushd . > /dev/null
|
|
|
|
cd "./tests/compile_tests/$test"
|
|
|
|
testResult=$("../../../$EXE" 2>&1)
|
|
|
|
ERR=$?
|
|
|
|
popd > /dev/null
|
|
|
|
|
|
|
|
(exit $ERR)
|
|
|
|
assert_success_named "run" "Execution Error:" echo "$testResult"
|
|
|
|
|
|
|
|
[ "$testResult" == "$expectedResult" ]
|
|
|
|
assert_success_named "result" "Result is wrong:" show_incorrect_result "$expectedResult" "$testResult"
|
2022-04-28 23:28:45 +00:00
|
|
|
done
|