diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-03-25 07:38:42 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-03-25 07:38:42 -0700 |
commit | b73c9b0a964ae6f2e3af5e597d7f98244f552efb (patch) | |
tree | d8413a4f9b935488fe3f0c829f1b7704ab884305 /testsuite.awk | |
parent | 595b367f6fd2d09e1489389ba999f73915309b5c (diff) | |
download | cppawk-b73c9b0a964ae6f2e3af5e597d7f98244f552efb.tar.gz cppawk-b73c9b0a964ae6f2e3af5e597d7f98244f552efb.tar.bz2 cppawk-b73c9b0a964ae6f2e3af5e597d7f98244f552efb.zip |
Use awk for testsuite rather than cppawk.
There are ways in which cppawk can be fundamentally broken
which will cause the test suite to appear to succeed, but
without actually running any tests.
Diffstat (limited to 'testsuite.awk')
-rwxr-xr-x | testsuite.awk | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/testsuite.awk b/testsuite.awk new file mode 100755 index 0000000..2c9fd14 --- /dev/null +++ b/testsuite.awk @@ -0,0 +1,32 @@ +#!/usr/bin/awk -f + +BEGIN { + RS = "--\n" + FS = ":\n" +} + +function runtest(id, code, output, + failed) +{ + print code > "script.sh" + print output > "output" + + failed = 0 + + if (output == "ERR\n") { + if (system("sh script.sh > /dev/null 2>&1") == 0) + failed = 1 + } else if (system("[ \"$(sh script.sh)\" = \"$(cat output)\" ]") != 0) { + failed = 1 + } + + if (failed) + printf("test %s failed (for cppawk = %s)\n", id, ENVIRON["cppawk"]) + + close("script.sh") + close("output") +} + +$1 { + runtest($1, $2, $3) +} |