]> git.draconx.ca Git - dxcommon.git/commitdiff
test-tap: Use m4_require to pull in global definitions.
authorNick Bowler <nbowler@draconx.ca>
Sat, 1 Jul 2023 20:53:08 +0000 (16:53 -0400)
committerNick Bowler <nbowler@draconx.ca>
Sat, 1 Jul 2023 20:53:08 +0000 (16:53 -0400)
We can use the m4_require machinery to pull in the PREPARE_TESTS bits,
so they only get included if/when the TEST_TAP macro is actually used.

snippet/test-tap.at

index 7941cb72474e4729f4ecfc0433acf4198ce8c847..cccea491342efd67d4649901aaa545d5ea14ecc4 100644 (file)
@@ -7,7 +7,7 @@
 # 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.
 
-m4_divert_push([PREPARE_TESTS])dnl
+m4_defun([_TEST_TAP_PREPARE], [m4_divert_push([PREPARE_TESTS])dnl
 {
   echo "% prove --version"
   prove --version </dev/null
@@ -17,7 +17,7 @@ m4_divert_push([PREPARE_TESTS])dnl
 # Run a test program, and, if prove is installed, use it to interpret the
 # TAP-formatted output.
 test_run_tap () {
-  program=$1; shift
+  program=$[1]; shift
 
   "$builddir/t/$program" "$@" >"$program.tap"
   status=$?
@@ -28,14 +28,15 @@ test_run_tap () {
   prove "$program.pl" 2>&1
   return $status
 }
-m4_divert_pop([PREPARE_TESTS])
+m4_divert_pop([PREPARE_TESTS])])
 
 dnl TEST_TAP([application])
 dnl
 dnl Run the given TAP application.  The exit status indicates the overall
 dnl success/failure of the test, while the application's TAP-formatted
 dnl output is logged with details of individual test results.
-m4_define([TEST_TAP], [AT_CHECK([test_run_tap $1], [0], [ignore])])
+m4_defun([TEST_TAP], [m4_require([_TEST_TAP_PREPARE])dnl
+AT_CHECK([test_run_tap $1], [0], [ignore])])
 
 dnl TEST_TAP_SIMPLE([name], [application], [setup], [keywords])
 dnl