From 25e5a26bf46adbe4c7cf44ff58aec071c4241e4c Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Sat, 18 Nov 2023 02:40:51 -0500 Subject: [PATCH] tests: Improve portability for perl script tests. 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 | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/tests/scripts.at b/tests/scripts.at index dbec2c9..a510f25 100644 --- a/tests/scripts.at +++ b/tests/scripts.at @@ -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" <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 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.16 1.17 1.18 1.19], [AS_VERSION_COMPARE(["$amver"], [1.16], [continue])]) -- 2.43.2