From: Stefano Lattarini Date: Mon, 6 Jun 2011 12:40:22 +0000 (+0200) Subject: tests: can use also $SHELL to check shell scripts from `lib/' X-Git-Tag: v1.11b~257^2~187^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2838ad57693eec3e8467460e61e1c0d98ec53d3b;p=platform%2Fupstream%2Fautomake.git 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. --- diff --git a/ChangeLog b/ChangeLog index 744a993..f2c4624 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,34 @@ 2011-06-07 Stefano Lattarini + 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 + 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 diff --git a/tests/ar-lib.test b/tests/ar-lib.test index 9936c0e8..6f6625d 100755 --- a/tests/ar-lib.test +++ b/tests/ar-lib.test @@ -19,7 +19,7 @@ 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' diff --git a/tests/compile.test b/tests/compile.test index 8427bad..0ba9ddf 100755 --- a/tests/compile.test +++ b/tests/compile.test @@ -18,7 +18,7 @@ . ./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) diff --git a/tests/compile2.test b/tests/compile2.test index a466dc4..180fcc3 100755 --- a/tests/compile2.test +++ b/tests/compile2.test @@ -18,7 +18,7 @@ . ./defs || Exit 1 -cp "$top_testsrcdir/lib/compile" . +get_shell_script compile cat >mycc <<'END' source_seen=no diff --git a/tests/compile3.test b/tests/compile3.test index 61cde6b..b703f66 100755 --- a/tests/compile3.test +++ b/tests/compile3.test @@ -19,7 +19,7 @@ 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' diff --git a/tests/compile4.test b/tests/compile4.test index cf8d6cb..c7e8a0e 100755 --- a/tests/compile4.test +++ b/tests/compile4.test @@ -20,6 +20,8 @@ required='cl' . ./defs || Exit 1 +get_shell_script compile + mkdir sub cat >sub/foo.c <<'EOF' diff --git a/tests/compile5.test b/tests/compile5.test index cd8baee..2b4eeb0 100755 --- a/tests/compile5.test +++ b/tests/compile5.test @@ -19,7 +19,7 @@ . ./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' diff --git a/tests/compile6.test b/tests/compile6.test index ca1c671..fff1487 100755 --- a/tests/compile6.test +++ b/tests/compile6.test @@ -19,7 +19,7 @@ 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' diff --git a/tests/defs b/tests/defs index 55596cf..e8ff92e 100644 --- a/tests/defs +++ b/tests/defs @@ -283,6 +283,23 @@ unindent () } 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. @@ -339,7 +356,12 @@ do 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" diff --git a/tests/instsh2.test b/tests/instsh2.test index 2019b35..f86c414 100755 --- a/tests/instsh2.test +++ b/tests/instsh2.test @@ -18,6 +18,9 @@ # 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 diff --git a/tests/instsh3.test b/tests/instsh3.test index da50419..2cdf4a9 100755 --- a/tests/instsh3.test +++ b/tests/instsh3.test @@ -23,6 +23,8 @@ required=non-root 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. diff --git a/tests/missing.test b/tests/missing.test index 2e6d8d3..8e080eb 100755 --- a/tests/missing.test +++ b/tests/missing.test @@ -25,6 +25,8 @@ EOF : > Makefile.am +get_shell_script missing + $ACLOCAL $AUTOCONF $AUTOMAKE --add-missing diff --git a/tests/missing2.test b/tests/missing2.test index 88e6b27..9844958 100755 --- a/tests/missing2.test +++ b/tests/missing2.test @@ -28,6 +28,8 @@ EOF : > Makefile.am +get_shell_script missing + $ACLOCAL $AUTOCONF $AUTOMAKE --add-missing diff --git a/tests/missing3.test b/tests/missing3.test index 21b5e4f..328212c 100755 --- a/tests/missing3.test +++ b/tests/missing3.test @@ -18,6 +18,8 @@ . ./defs || Exit 1 +get_shell_script missing + # b7cb8259 assumed not to exist. ./missing b7cb8259 --version 2>stderr && { cat stderr >&2; Exit 1; } diff --git a/tests/missing5.test b/tests/missing5.test index 010b344..b618bd1 100755 --- a/tests/missing5.test +++ b/tests/missing5.test @@ -19,6 +19,8 @@ . ./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'` diff --git a/tests/mkinst3.test b/tests/mkinst3.test index 0082b53..3572ab2 100755 --- a/tests/mkinst3.test +++ b/tests/mkinst3.test @@ -23,7 +23,7 @@ mkdir '~a b' && mkdir '~a b/-x y' \ || 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.