t/ax/test-init.sh


Log

Author Commit Date CI Message
Stefano Lattarini c2a52bf0 2012-06-24T10:36:15 tests: simpler workaround for shells losing the exit status in exit trap Now that we can assume our tests are run by a decent POSIX shell, we can simplify our workaround aimed at having the exit status propagated correctly to the code in the exit trap. Unfortunately, we cannot dispense with such a workaround altogether, because it's still required by some shells we need to support (at least Solaris 10 /bin/ksh and /usr/xpg4/bin/sh). For more information about the need of that workaround, see the entry about 'trap' in the section "Limitations of Shell Builtins" in the Autoconf manual: <http://www.gnu.org/software/autoconf/manual/autoconf.html#trap> The new workaround has been tested successfully with the following shells: - Bash 4.1 - Bash 3.2 - Bash 3.0 - Bash 2.05b - dash 0.5.5.1 - dash 0.5.2 - AT&T Ksh 93u (from official Debian package) - MirBSD Korn Shell 40.2 (from official Debian package) - Solaris 9, 10 and 11 /bin/ksh - Solaris 9, 10 and 11 /usr/xpg4/bin/sh - NetBSD 5.1 /bin/sh - NetBSD 5.1 /bin/ksh * t/ax/test-init.sh (Exit): Rename ... (_am_exit): ... like this. (exit): New alias for '_am_exit'. We cannot simply redefine 'exit' as a shell function, because some shells (dash 0.5.5.1, Solaris 10 /bin/ksh and /usr/xpg4/bin/sh) do not allow it. (_am_exit, trap): Add extra escaping for 'exit' calls, to ensure we really invoke the 'exit' builtin and not our alias with the same name. * configure.ac: Check that the shell selected to run our testsuite supports aliases named like shell builtins. * t/REAMDE: Adjust. * All tests: Adjust, by simply using 'exit' instead of 'Exit'. * t/self-check-explicit-skips.sh: Adjust: the first usage of 'exit' after it has been redefined as an alias must be on a new line w.r.t. that where the alias is defined, in order for the redefinition to be honored. * syntax-checks.mk (sc_tests_Exit_not_exit): Delete. (sc_tests_exit_not_Exit): New. (syntax_check_rules): Adjust. (sc_tests_automake_fails): Simplify the recipe a little. * Several tests: Remove now useless spurious quoting once required to placate the 'sc_tests_Exit_not_exit' maintainer check. * gen-testsuite-part: Likewise. Also, avoid uses of 'Exit' in the generated scripts. Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Stefano Lattarini 5898641f 2012-06-23T00:12:08 tests: avoid one last `...` command substitution in 'test-init.sh' * t/ax/test-init.sh (me): In the definition of this variable. This also shave off a couple of forks, and the need for a sanity check only required in fringe situations. Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Stefano Lattarini 19c56b1d 2012-06-22T22:31:35 tests: new requirement 'grep-nonprint' * t/ax/test-inist.sh ($esc): New, a literal escape character. (grep-nonprint): New requirement, check that the grep implementation available that can handle non-printing characters correctly. * t/color.sh: Use it instead of hand-rolled equivalent, and do not (re)define '$esc' explicitly. * t/color2.sh: Likewise. * t/tap-color.sh: Likewise. * t/vtexi4.sh: Likewise. * t/parallel-tests-no-color-in-log.sh: Likewise. Also prefer the use of grep over that of $FGREP, because the new requirement only check grep, and ensure we only grep non-printing characters from a pipe, to avoid hitting a BSD grep limitation. * t/parallel-tests-reset-term.sh: Likewise. * t/ax/tap-summary-aux.sh: Use '$esc' instead of hard-coding the literal escape character. Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Stefano Lattarini dc18830f 2012-06-22T16:18:28 tests: implement is_newest as an auxiliary script, not shell function This will allow to also use it in the makefile recipes used in our test cases. * t/ax/test-init.sh (is_newest): Remove. * t/ax/is_newest: New script. * Makefile.am (EXTRA_DIST): Add it. Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Stefano Lattarini 3a1a8c6d 2012-06-22T11:40:39 tests: automatic re-execution works for non-POSIX shells too Some inferior shells are too greedy in parsing their input. If a non-POSIX Bourne shell (like Solaris 10 /bin/sh) was used to launch one of our test scripts, it would fail unconditionally, because it unexpectedly saw some (by it) unsupported constructs, notwithstanding such constructs being placed *after* the code implementing automatic test re-execution with a better shell. In conclusion, the shell bailed out like this: $ /bin/sh t/ar.sh $ t/ar.sh: syntax error at line 257: `is_newest_files=$' unexpected By moving all the potentially problematic code in a separate file, to be sourced only after the code for automatic re-execution with a better shell, we ensure that inferior shell cannot see such code by mistake. * defs: All code after automatic shell re-execution moved out ... * t/ax/test-init.sh: ... to this new file. * syntax-checks.mk (xdefs): Add it. * Makefile.am (dist_check_DATA): Add it. Also move in 'defs' from a less explicit 'check_DATA' declaration. (nodist_check_DATA): Move in 'defs-static' from a less explicit 'check_DATA' declaration. (check_DATA): Remove. * t/self-check-sanity.sh: Remove, it was actually too hacky and brittle, sanity-checking situations we don0t actually care about. * t/list-of-tests.mk: Adjust. * t/self-check-explicit-skips.sh: Adjust, and fix a botched heading comments while we are at it. * t/self-check-reexec.tap: Adjust. * t/self-check-cleanup.tap: Likewise. Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>