From 90bd48c414b9e6d53eeca76b9fea92cafc3883d6 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 18 Mar 2022 07:42:59 -0700 Subject: Check that -f without argument fails. --- testcases | 5 +++++ testsuite.cwk | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/testcases b/testcases index ba4ed64..8797315 100644 --- a/testcases +++ b/testcases @@ -7,3 +7,8 @@ hello ./cppawk -M 'BEGIN { print 1000000000000000000000000 + 1 }' : 1000000000000000000000001 +-- +3: +./cppawk -f +: +ERR diff --git a/testsuite.cwk b/testsuite.cwk index ce495d0..fd8fa7d 100755 --- a/testsuite.cwk +++ b/testsuite.cwk @@ -5,15 +5,24 @@ BEGIN { FS = ":\n" } -function runtest(id, code, output) +function runtest(id, code, output, + failed) { print code > "script.sh" print output > "output" - if (system("[ \"$(sh script.sh)\" = \"$(cat output)\" ]") != 0) { - printf("test %s failed\n", id) + 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\n", id) + close("script.sh") close("output") } -- cgit v1.2.3