]> git.draconx.ca Git - dxcommon.git/commitdiff
test-tap.at: Fix regression passing program arguments.
authorNick Bowler <nbowler@draconx.ca>
Sat, 6 Jan 2024 07:34:10 +0000 (02:34 -0500)
committerNick Bowler <nbowler@draconx.ca>
Sat, 6 Jan 2024 07:34:10 +0000 (02:34 -0500)
Moving the test_run_tap() function definition into a macro failed to
properly quote $@ so it isn't eaten by m4.  So instead of calling
the test program with "$@" as the argument, it is changed to "".

Fix that up, and add a very simple test case to check this behaviour.

snippet/test-tap.at
t/tapcheck.sh [new file with mode: 0755]
tests/snippets.at

index 2873cf463b41754320fe72365698afbc35f2fb83..ee4b54138268b1d0b228018c609d2bb2aad79b3b 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright © 2015, 2022-2023 Nick Bowler
+# Copyright © 2015, 2022-2024 Nick Bowler
 #
 # Helper macros for executing the TAP-like applications in an autotest
 # test suite.
@@ -19,7 +19,7 @@ m4_defun([_TEST_TAP_PREPARE], [m4_divert_push([PREPARE_TESTS])dnl
 test_run_tap () {
   program=$[1]; shift
 
-  "$builddir/t/$program" "$@" >"$program.tap"
+  "$builddir/t/$program" "$[@]" >"$program.tap"
   status=$?
   cat "$program.tap"
   # Older versions of prove do not support the -e option so the
diff --git a/t/tapcheck.sh b/t/tapcheck.sh
new file mode 100755 (executable)
index 0000000..85dd2f7
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# Copyright © 2024 Nick Bowler
+#
+# Fake TAP test program for testing the autotest snippets.
+#
+# License WTFPL2: Do What The Fuck You Want To Public License, version 2.
+# This is free software: you are free to do what the fuck you want to.
+# There is NO WARRANTY, to the extent permitted by law.
+
+total=$1; shift
+pass=0
+seq=0
+
+echo "1..$total"
+for arg
+do
+  seq=`expr 1 + $seq`
+  if eval "$arg" >/dev/null 2>&1; then
+    echo "ok $seq"
+    pass=`expr 1 + $pass`
+  else
+    echo "not ok $seq"
+  fi
+done
+
+test $pass -eq $total
index 8e2f2429ccaa55f7a727809a5ede99cb53e17227..dc37d6bc43db51965418e37055d511f78146099b 100644 (file)
@@ -1,4 +1,4 @@
-dnl Copyright © 2021-2023 Nick Bowler
+dnl Copyright © 2021-2024 Nick Bowler
 dnl
 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
 dnl This is free software: you are free to do what the fuck you want to.
@@ -183,3 +183,5 @@ l0/b/LC_MESSAGES
 ]])
 
 AT_CLEANUP
+
+TEST_TAP_SIMPLE([test-tap.at sanity], [tapcheck.sh 4 : : : :], [], [autotest])