aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-03-18 07:42:59 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-03-18 07:42:59 -0700
commit90bd48c414b9e6d53eeca76b9fea92cafc3883d6 (patch)
tree2df5d2b6857e0732affac4eb06092a6d3adce022
parent4dd985c97390ece2596738206850a06cdeeb6b09 (diff)
downloadcppawk-90bd48c414b9e6d53eeca76b9fea92cafc3883d6.tar.gz
cppawk-90bd48c414b9e6d53eeca76b9fea92cafc3883d6.tar.bz2
cppawk-90bd48c414b9e6d53eeca76b9fea92cafc3883d6.zip
Check that -f without argument fails.
-rw-r--r--testcases5
-rwxr-xr-xtestsuite.cwk15
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")
}