]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
tests: can use also $SHELL to check shell scripts from `lib/'
authorStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 6 Jun 2011 12:40:22 +0000 (14:40 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 7 Jun 2011 10:09:02 +0000 (12:09 +0200)
* 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.

16 files changed:
ChangeLog
tests/ar-lib.test
tests/compile.test
tests/compile2.test
tests/compile3.test
tests/compile4.test
tests/compile5.test
tests/compile6.test
tests/defs
tests/instsh2.test
tests/instsh3.test
tests/missing.test
tests/missing2.test
tests/missing3.test
tests/missing5.test
tests/mkinst3.test

index 744a9939f06c6336113bf7762b79114f3fd5e04e..f2c4624fa4bdc4a561042e9b860d701de97624b2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+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
index 9936c0e8d4dbbb8cb39bc63abb7f1bf0370f9078..6f6625dc8ba03099d99581993a4f18e796dea8cc 100755 (executable)
@@ -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'
index 8427bad09c796153c9980c3f2fdf40afd4d66d25..0ba9ddf8101f1dad209e3d8a0d00773dec65a640 100755 (executable)
@@ -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)
index a466dc4130e0a3c5da05228c6f991d66fc3e3846..180fcc36e428117a4eb6d5e60d3ee23f4ab13234 100755 (executable)
@@ -18,7 +18,7 @@
 
 . ./defs || Exit 1
 
-cp "$top_testsrcdir/lib/compile" .
+get_shell_script compile
 
 cat >mycc <<'END'
 source_seen=no
index 61cde6bfbfac47160b58ed3ce806246da1c4da0d..b703f66de2bad9b793a5f1d98dd29a86d9d3866c 100755 (executable)
@@ -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'
index cf8d6cb7dbe0ac4095badd486fbf75650cf42399..c7e8a0e1873ce9768017ee8d3a0fe7c16e57f69c 100755 (executable)
@@ -20,6 +20,8 @@
 required='cl'
 . ./defs || Exit 1
 
+get_shell_script compile
+
 mkdir sub
 
 cat >sub/foo.c <<'EOF'
index cd8baee3ca0cd80a45f89e3eeeb089bd880286cd..2b4eeb0410c9d239645bf5df7ff40920e727719a 100755 (executable)
@@ -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'
index ca1c671783d8fb7542d3cd5abd6d6cd09a8834f1..fff14876dde629de19e8b15bd5d8463eb47c4d80 100755 (executable)
@@ -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'
index 55596cf749ed935840bb0d8dd5ac99d47aac944e..e8ff92e0ab05b6d1816f383bc42408162f6f0801 100644 (file)
@@ -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"
index 2019b357f03a0f7eb02946b911ac315a29572f28..f86c414c2792e59dafc017453fcf668fe95e6cd8 100755 (executable)
@@ -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
index da504190558f68eb0cf3c2eb7d0dea32008e470f..2cdf4a9e79aa6ec5ca3ba42e367761d898d2c376 100755 (executable)
@@ -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.
index 2e6d8d38274c67412586545e28fa4b12914c8bce..8e080eb59424ede853595da0a10c9081fc0ba0e2 100755 (executable)
@@ -25,6 +25,8 @@ EOF
 
 : > Makefile.am
 
+get_shell_script missing
+
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE --add-missing
index 88e6b27a66c89b61a10da64f3462a6abf935ba5c..9844958a7d9753fbab4e4a88ba966c72aea49cf3 100755 (executable)
@@ -28,6 +28,8 @@ EOF
 
 : > Makefile.am
 
+get_shell_script missing
+
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE --add-missing
index 21b5e4fa753704a5a17105a2d189ee869d02b89e..328212c4a850d6221d10a261f35b509d2a24c8b4 100755 (executable)
@@ -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; }
index 010b344d278a096a6b3fcab3d9be6bd1b1df7a48..b618bd1ee08af53d4d440f3d367b87d847480d65 100755 (executable)
@@ -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'`
index 0082b53fb6815fbe7c0fa3a32dbc22e680b007a3..3572ab2788a28623dfdd8cc4d1bfbfaa7e8fe8af 100755 (executable)
@@ -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.