]> git.draconx.ca Git - dxcommon.git/commitdiff
tests: Improve portability for perl script tests.
authorNick Bowler <nbowler@draconx.ca>
Sat, 18 Nov 2023 07:40:51 +0000 (02:40 -0500)
committerNick Bowler <nbowler@draconx.ca>
Sat, 18 Nov 2023 21:39:56 +0000 (16:39 -0500)
Older versions of perl do not recognize the "-f" option, which I think
was just used by mistake anyway, so we can just remove it.

Sed commands like /foo/{g;p} are not portable; POSIX requires it to be
written like:

  /foo/{
  g
  p
  }

HP-UX 11 sed does not interpret "-f -" to mean "read the script from
standard input", as intended; it looks for a file called - instead.
There is little reason to do this, we can just quote the script
normally.

Fixing all this allows the tests to run on HP-UX 11.

tests/scripts.at

index dbec2c9024e9d54ec4b133aa6cf34b0a053561b6..a510f2529e9a2a718e86279d447240f8850b5bb7 100644 (file)
@@ -848,24 +848,25 @@ AT_CLEANUP
 m4_divert_push([PREPARE_TESTS])dnl
 test_fix_ltdl () {
   $PERL -e 'my $x = 42; exit $x;'; test $? = 42 || exit 77
-  $PERL -f "$srcdir/scripts/fix-ltdl.pl" "$@"
+  $PERL "$srcdir/scripts/fix-ltdl.pl" "$@"
 }
 test_fix_gnulib () {
   $PERL -e 'my $x = 42; exit $x;'; test $? = 42 || exit 77
-  $PERL -f "$srcdir/scripts/fix-gnulib.pl" "$@"
+  $PERL "$srcdir/scripts/fix-gnulib.pl" "$@"
 }
 test_gnulib_mk () {
   echo;
   for arg
   do
-    sed -n -f - "$srcdir/tests/data/gnulib.mk" <<EOF
-/^## begin gnulib module $arg/,/^## end   gnulib module $arg/p
-EOF
+    sed -n -e \
+      "/^## begin gnulib module $arg/,/^## end   gnulib module $arg/p" \
+      "$srcdir/tests/data/gnulib.mk"
   done
 }
 m4_divert_pop([PREPARE_TESTS])
 
 AT_SETUP([fix-gnulib.pl SED_HEADER variables])
+AT_KEYWORDS([fix-gnulib perl script scripts])
 
 test_gnulib_mk gen-header >test.mk.in
 AT_CHECK([grep SED_HEADER test.mk.in >expout || exit 99])
@@ -875,21 +876,29 @@ grep SED_HEADER test.mk], [0], [expout])
 AT_CLEANUP
 
 AT_SETUP([fix-gnulib.pl %reldir% substitution])
+AT_KEYWORDS([fix-gnulib perl script scripts])
 
 test_gnulib_mk sys_types >test.mk.in
 AT_CHECK([grep '%reldir%' test.mk.in >/dev/null || exit 99])
 
-sed -n -f - test.mk.in >expout <<'EOF'
-${G;p;b}
+sed -n <test.mk.in >expout '
+$G
+$p
+$b
 /^## begin gnulib/,/^## end   gnulib/!b
-/^#/{p;b}
+/^#/{
+p
+b
+}
 s|(srcdir)|(top_srcdir)|
 s|%reldir%|lib|
 s|BUILT_SOURCES|gnulib_core_headers|
 s|sys[[/_]]|lib/&|g
-/^MOSTLYCLEANFILES/{h;b}
-p
-EOF
+/^MOSTLYCLEANFILES/{
+h
+b
+}
+p'
 
 AT_CHECK([test_fix_gnulib -i test.mk.in -o test.mk || exit
 sed -n -e '/^## begin gnulib/,/^## end   gnulib/p' \
@@ -899,6 +908,7 @@ sed -n -e '/^## begin gnulib/,/^## end   gnulib/p' \
 AT_CLEANUP
 
 AT_SETUP([fix-gnulib.pl warning removal])
+AT_KEYWORDS([fix-gnulib perl script scripts])
 
 AT_DATA([test.mk.in], [[
 ## test begin
@@ -918,6 +928,7 @@ EXTRA_LIBRARIES += libgnu.a
 AT_CLEANUP
 
 AT_SETUP([fix-gnulib.pl header directory creation])
+AT_KEYWORDS([fix-gnulib perl script scripts])
 
 AT_DATA([extract.sed],
 [[/AM_V_GEN/b ok
@@ -1025,6 +1036,7 @@ helloworld
 ])])
 
 AT_SETUP([fix-ltdl.pl LIBOBJ mangling (<automake-1.16)])
+AT_KEYWORDS([fix-ltdl perl script scripts])
 
 TEST_FIND_AUTOMAKE([default 1.10 1.11 1.12 1.13 1.14 1.15],
   [AS_VERSION_COMPARE(["$amver"], [1.16], [], [continue], [continue])])
@@ -1033,6 +1045,7 @@ TEST_LTDL_LIBOBJ_MANGLING
 AT_CLEANUP
 
 AT_SETUP([fix-ltdl.pl LIBOBJ mangling (>=automake-1.16)])
+AT_KEYWORDS([fix-ltdl perl script scripts])
 
 TEST_FIND_AUTOMAKE([default 1.16 1.17 1.18 1.19],
   [AS_VERSION_COMPARE(["$amver"], [1.16], [continue])])