summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-01-18 22:35:57 +0100
committerMattias Andrée <maandree@kth.se>2022-01-18 22:36:27 +0100
commit5bd637a82768badf2208636b6f3b28b33049d593 (patch)
treee6925004f2a25e178578f40b1f072ac23efca415 /test
parentDo not run check by default (diff)
downloadmakel-5bd637a82768badf2208636b6f3b28b33049d593.tar.gz
makel-5bd637a82768badf2208636b6f3b28b33049d593.tar.bz2
makel-5bd637a82768badf2208636b6f3b28b33049d593.tar.xz
test: add missing quotes, allow : in extra options, use printf instead of echo, print to stderr and not stdout, and some style changes
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'test')
-rwxr-xr-xtest34
1 files changed, 19 insertions, 15 deletions
diff --git a/test b/test
index f8fc26c..5b10901 100755
--- a/test
+++ b/test
@@ -3,24 +3,28 @@
# Every test file must start with a line formatted as follows:
# #:<exit code>:<additional makel command line options>
+exec >&2
+
nfails=0
+
for f in tests/*.mk; do
- header=$(head -n1 "$f")
- exp=$(echo "$header" | cut -d: -f2)
- options=$(echo "$header" | cut -d: -f3)
- ./makel -f$f $options 2>/dev/null 1>/dev/null
+ header="$(head -n 1 < "$f")"
+ expected=$(printf '%s' "$header" | cut -d : -f 2)
+ options="$(printf '%s' "$header" | cut -d : -f 3-)"
+
+ ./makel -f "$f" $options >/dev/null 2>/dev/null
got=$?
- if [ $got -lt $exp ]; then
- echo "$f: defect was not detected (expected $exp, got $got)"
- nfails=$((nfails+1))
- fi
- if [ $got -gt $exp ]; then
- echo "$f: found more serious defects than expected (expected $exp, got $got)"
- nfails=$((nfails+1))
+
+ if test $got -lt $expected; then
+ printf '%s: %s\n' "$f" "defect was not detected (expected ${expected}, got ${got})"
+ : $(( nfails++ ))
+ elif test $got -gt $expected; then
+ printf '%s: %s\n' "$f" "found more serious defects than expected (expected ${expected}, got ${got})"
+ : $(( nfails++ ))
fi
done
-if [ $nfails -gt 0 ]; then
- echo "----------"
- echo "$nfails tests returned different exit codes than expected."
-fi
+if test $nfails -gt 0; then
+ printf '%s\n' '----------'
+ printf '%s\n' "${nfails} tests returned different exit codes than expected."
+fi