2011-06-07 Stefano Lattarini <stefano.lattarini@gmail.com>
+ tests: can use also $SHELL to check shell scripts from `lib/'
+ * tests/ar-lib.test: If the variable `$test_prefer_config_shell'
+ is set to "yes", run the script under test with configure-time
+ determined $SHELL, rather than with /bin/sh.
+ The `$test_prefer_config_shell' variable defaults to empty, but
+ can be overridden at runtime by the user, thus allowing more
+ coverage.
+ * tests/compile.test: Likewise.
+ * tests/compile2.test: Likewise.
+ * tests/compile3.test: Likewise.
+ * tests/compile4.test: Likewise.
+ * tests/compile5.test: Likewise.
+ * tests/compile6.test: Likewise.
+ * tests/instsh2.test: Likewise.
+ * tests/instsh3.test: Likewise.
+ * tests/mkinst3.test: Likewise.
+ * tests/missing.test: Likewise.
+ * tests/missing2.test: Likewise.
+ * tests/missing3.test: Likewise.
+ * tests/missing5.test: Likewise.
+ * tests/defs (get_shell_script): New subroutine, factoring out
+ code common to the tests above.
+ (xsi-lib-shell): If `$test_prefer_config_shell' is set to "yes",
+ check that $SHELL, not /bin/sh, supports XSI constructs, as we
+ expect the test will use $SHELL and not /bin/sh to run the
+ script being tested.
+
+2011-06-07 Stefano Lattarini <stefano.lattarini@gmail.com>
+
tests defs: better requirements for XSI shells
This change avoids potential spurious failures with tests using
the requirement 'xsi-shell' to mean that they want */bin/sh* (not
required=xsi-lib-shell
. ./defs || Exit 1
-cp "$top_testsrcdir/lib/ar-lib" .
+get_shell_script ar-lib
# Use a dummy lib, since lib isn't readily available on all systems.
cat >lib <<'END'
. ./defs || Exit 1
-cp "$top_testsrcdir/lib/compile" .
+get_shell_script compile
# -o 'a c' should not be stripped because 'a c' is not an object
# (it does not matter whether touch creates ./-- or not)
. ./defs || Exit 1
-cp "$top_testsrcdir/lib/compile" .
+get_shell_script compile
cat >mycc <<'END'
source_seen=no
required=xsi-lib-shell
. ./defs || Exit 1
-cp "$top_testsrcdir/lib/compile" .
+get_shell_script compile
# Use a dummy cl, since cl isn't readily available on all systems
cat >cl <<'END'
required='cl'
. ./defs || Exit 1
+get_shell_script compile
+
mkdir sub
cat >sub/foo.c <<'EOF'
. ./defs || Exit 1
-cp "$top_testsrcdir/lib/compile" .
+get_shell_script compile
# Use a dummy cl, since cl isn't readily available on all systems
cat >cl <<'END'
required=xsi-lib-shell
. ./defs || Exit 1
-cp "$top_testsrcdir/lib/compile" .
+get_shell_script compile
# Use a dummy cl, since cl isn't readily available on all systems
cat >cl <<'END'
}
sed_unindent_prog="" # Avoid interferences from the environment.
+# get_shell_script SCRIPT-NAME
+# -----------------------------
+# Fetch an Automake-provided test script from the `lib/' directory into
+# the current directory, and, if the `$test_prefer_config_shell' variable
+# is set to "yes", modify its shebang line to use $SHELL instead of
+# /bin/sh.
+get_shell_script ()
+{
+ if test x"$test_prefer_config_shell" = x"yes"; then
+ sed "1s|#!.*|#! $SHELL|" "$top_testsrcdir/lib/$1" > "$1"
+ chmod a+x "$1"
+ else
+ cp "$top_testsrcdir/lib/$1" .
+ fi
+ sed 10q "$1" # For debugging.
+}
+
# require_xsi SHELL
# -----------------
# Skip the test if the given shell fails to support common XSI constructs.
xsi-bin-sh)
require_xsi "/bin/sh";;
xsi-lib-shell)
- require_xsi "/bin/sh";;
+ if test x"$test_prefer_config_shell" = x"yes"; then
+ require_xsi "$SHELL"
+ else
+ require_xsi "/bin/sh"
+ fi
+ ;;
bzip2)
# Do not use --version, bzip2 still tries to compress stdin.
echo "$me: running bzip2 --help"
# Various install-sh checks
. ./defs || Exit 1
+
+get_shell_script install-sh
+
# Basic errors
./install-sh && Exit 1
./install-sh -m 644 dest && Exit 1
touch -t $old_timestamp foo \
|| skip_ "touch utility doesn't accept '-t' option"
+get_shell_script install-sh
+
./install-sh -d d1
# Do not change the timestamps when using -C.
: > Makefile.am
+get_shell_script missing
+
$ACLOCAL
$AUTOCONF
$AUTOMAKE --add-missing
: > Makefile.am
+get_shell_script missing
+
$ACLOCAL
$AUTOCONF
$AUTOMAKE --add-missing
. ./defs || Exit 1
+get_shell_script missing
+
# b7cb8259 assumed not to exist.
./missing b7cb8259 --version 2>stderr && { cat stderr >&2; Exit 1; }
. ./defs || Exit 1
+get_shell_script missing
+
# these programs may be invoked by `missing'
needed_tools='chmod find sed test touch'
needed_tools_csep=`echo $needed_tools | sed 's/ /, /g'`
|| skip_ "directory names with spaces and metacharacters not accepted"
rm -rf '~a b'
-cp "$top_testsrcdir/lib/mkinstalldirs" .
+get_shell_script mkinstalldirs
# Test mkinstalldirs with the installed mkdir.