From adb52f4f041b575ea4aa4bd2b7061d97150375e6 Mon Sep 17 00:00:00 2001 From: Matthew Kilgore Date: Sun, 4 Sep 2022 03:04:39 -0400 Subject: [PATCH] Add support for custom flags on QB64 tests --- docs/testing.md | 3 +++ tests/compile_tests.sh | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/testing.md b/docs/testing.md index f74ab3da7..3a1952ef3 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -17,6 +17,9 @@ the program compiled from the `*.bas` file should produce. For `*.err` tests, the `*.err` file contains the text of the error the QB64-PE compiler should produce when attempting to compile that code. +Tests can also have an optional `*.flags` file. The contents of this file will +be provide as command line arguments to QB64-PE when compiling the test source. + These tests are run via the `./tests/compile_tests.sh` script. The script searches the `./tests/compile_tests` directory for any `*.bas` files, and then uses the provide QB64-PE compiler to test them. diff --git a/tests/compile_tests.sh b/tests/compile_tests.sh index 66cbedd53..79783667b 100755 --- a/tests/compile_tests.sh +++ b/tests/compile_tests.sh @@ -50,7 +50,14 @@ do compileResultOutput="$RESULTS_DIR/$category-$testName-compile_result.txt" - "$QB64" -q -x "./tests/compile_tests/$category/$testName.bas" -o "$EXE" 1>"$compileResultOutput" + # A .flags file contains any extra compiler flags to provide to QB64 for this test + compilerFlags= + if test -f "./tests/compile_tests/$category/$testName.flags"; then + compilerFlags=$(cat "./tests/compile_tests/$category/$testName.flags") + fi + + # -m and -q make sure that we get predictable results + "$QB64" $compilerFlags -m -q -x "./tests/compile_tests/$category/$testName.bas" -o "$EXE" 1>"$compileResultOutput" ERR=$? cp_if_exists ./internal/temp/compilelog.txt "$RESULTS_DIR/$category-$testName-compilelog.txt"