]> Savannah Git Hosting - gnulib.git/commitdiff
tests: Accommodate a shell that is not in /bin/sh.
authorBruno Haible <bruno@clisp.org>
Sun, 27 Jan 2019 15:01:23 +0000 (16:01 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 27 Jan 2019 15:01:23 +0000 (16:01 +0100)
* tests/init.sh (setup_): Set srcdir and builddir.
(BOURNE_SHELL): New variable.
* modules/acl-tests (Depends-on): Add 'test-framework-sh'.
* modules/file-has-acl-tests (Depends-on): Likewise.
* modules/copy-file-tests (Depends-on): Likewise.
* tests/test-set-mode-acl-1.sh: Use the test framework. Invoke shell
scripts through $BOURNE_SHELL.
* tests/test-set-mode-acl-2.sh: Likewise.
* tests/test-copy-acl-1.sh: Likewise.
* tests/test-copy-acl-2.sh: Likewise.
* tests/test-file-has-acl-1.sh: Likewise.
* tests/test-file-has-acl-2.sh: Likewise.
* tests/test-copy-file-1.sh: Likewise.
* tests/test-copy-file-2.sh: Likewise.
* tests/test-set-mode-acl.sh (builddir): Consider value set by the
invoker.
* tests/test-copy-acl.sh (builddir): Likewise.
* tests/test-file-has-acl.sh (builddir): Likewise.
* tests/test-copy-file.sh (builddir): Likewise.
* tests/test-vc-list-files-cvs.sh: Don't create shims for executables in
build-aux/. Instead, invoke shell scripts through $BOURNE_SHELL.
* tests/test-vc-list-files-git.sh: Likewise.

19 files changed:
ChangeLog
modules/acl-tests
modules/copy-file-tests
modules/file-has-acl-tests
tests/init.sh
tests/test-copy-acl-1.sh
tests/test-copy-acl-2.sh
tests/test-copy-acl.sh
tests/test-copy-file-1.sh
tests/test-copy-file-2.sh
tests/test-copy-file.sh
tests/test-file-has-acl-1.sh
tests/test-file-has-acl-2.sh
tests/test-file-has-acl.sh
tests/test-set-mode-acl-1.sh
tests/test-set-mode-acl-2.sh
tests/test-set-mode-acl.sh
tests/test-vc-list-files-cvs.sh
tests/test-vc-list-files-git.sh

index d7d1f81d555b42de535ff8a095b1de89997ced31..3e60f82bb737a69e79f51122b13e043739199f3a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2019-01-27  Bruno Haible  <bruno@clisp.org>
+
+       tests: Accommodate a shell that is not in /bin/sh.
+       * tests/init.sh (setup_): Set srcdir and builddir.
+       (BOURNE_SHELL): New variable.
+       * modules/acl-tests (Depends-on): Add 'test-framework-sh'.
+       * modules/file-has-acl-tests (Depends-on): Likewise.
+       * modules/copy-file-tests (Depends-on): Likewise.
+       * tests/test-set-mode-acl-1.sh: Use the test framework. Invoke shell
+       scripts through $BOURNE_SHELL.
+       * tests/test-set-mode-acl-2.sh: Likewise.
+       * tests/test-copy-acl-1.sh: Likewise.
+       * tests/test-copy-acl-2.sh: Likewise.
+       * tests/test-file-has-acl-1.sh: Likewise.
+       * tests/test-file-has-acl-2.sh: Likewise.
+       * tests/test-copy-file-1.sh: Likewise.
+       * tests/test-copy-file-2.sh: Likewise.
+       * tests/test-set-mode-acl.sh (builddir): Consider value set by the
+       invoker.
+       * tests/test-copy-acl.sh (builddir): Likewise.
+       * tests/test-file-has-acl.sh (builddir): Likewise.
+       * tests/test-copy-file.sh (builddir): Likewise.
+       * tests/test-vc-list-files-cvs.sh: Don't create shims for executables in
+       build-aux/. Instead, invoke shell scripts through $BOURNE_SHELL.
+       * tests/test-vc-list-files-git.sh: Likewise.
+
 2019-01-27  Bruno Haible  <bruno@clisp.org>
 
        tests: Fix some "unused variable" warnings.
index 3438f146f3dc13ab063a886030877c301ecc49b4..76e2a36173982b70687c8d86b5a6808d7ae66c95 100644 (file)
@@ -15,6 +15,7 @@ file-has-acl-tests
 read-file
 unistd
 xalloc
+test-framework-sh
 
 configure.ac:
 
index 299d49fc531ce567da08811deb128e23de5d5cc9..6b468afbfc7e7f22fb7d24909234a532e5b597d8 100644 (file)
@@ -10,6 +10,7 @@ acl
 acl-tests
 read-file
 xalloc
+test-framework-sh
 
 configure.ac:
 
index 5a26020bdeb8dce8a396a00fc07eb9be08359e88..ff069ec52d46fd0299b1b366caf8313e0e4389bf 100644 (file)
@@ -7,6 +7,7 @@ tests/macros.h
 
 Depends-on:
 unistd
+test-framework-sh
 
 configure.ac:
 AC_CHECK_DECLS_ONCE([alarm])
index 0d6ddee3a1d2fe13444cf10bb972bf01f726f99c..9498d837ec9b8ad484adbcc38a6ffc5091e75c57 100644 (file)
@@ -475,10 +475,18 @@ setup_ ()
 
   initial_cwd_=$PWD
 
+  # Create and enter the temporary directory.
   pfx_=`testdir_prefix_`
   test_dir_=`mktempd_ "$initial_cwd_" "$pfx_-$ME_.XXXX"` \
     || fail_ "failed to create temporary directory in $initial_cwd_"
   cd "$test_dir_" || fail_ "failed to cd to temporary directory"
+  # Set variables srcdir, builddir, for the convenience of the test.
+  case $srcdir in
+    /* | ?:*) ;;
+    *) srcdir="../$srcdir" ;;
+  esac
+  builddir=".."
+  export srcdir builddir
 
   # As autoconf-generated configure scripts do, ensure that IFS
   # is defined initially, so that saving and restoring $IFS works.
@@ -607,6 +615,15 @@ mktempd_ ()
   fail_ "$err_"
 }
 
+# The interpreter for Bourne-shell scripts.
+# No special standards compatibility requirements.
+# Some environments, such as Android, don't have /bin/sh.
+if test -f /bin/sh$EXEEXT; then
+  BOURNE_SHELL=/bin/sh
+else
+  BOURNE_SHELL=sh
+fi
+
 # If you want to override the testdir_prefix_ function,
 # or to add more utility functions, use this file.
 test -f "$srcdir/init.cfg" \
index 2f9880e04f739af15f5ca4f9080659fb49266d37..bb6009172961fafc5a9f436c626b3c631f884f5e 100755 (executable)
@@ -3,6 +3,8 @@
 # Test copy-acl on the file system of /var/tmp, which usually is a local
 # file system.
 
+. "${srcdir=.}/init.sh"; path_prepend_ .
+
 if test -d /var/tmp; then
   TMPDIR=/var/tmp
 else
@@ -10,4 +12,6 @@ else
 fi
 export TMPDIR
 
-exec "${srcdir}/test-copy-acl.sh"
+$BOURNE_SHELL "${srcdir}/test-copy-acl.sh"
+
+Exit $?
index 984602d9c9e09e3ae4bd237a7de843684e4648bf..a35c12eba1e23be529c03a4a7a5fa5d963b794c5 100755 (executable)
@@ -3,7 +3,11 @@
 # Test copy-acl on the file system of the build directory, which may be
 # a local file system or NFS mounted.
 
+. "${srcdir=.}/init.sh"; path_prepend_ .
+
 TMPDIR=`pwd`
 export TMPDIR
 
-exec "${srcdir}/test-copy-acl.sh"
+$BOURNE_SHELL "${srcdir}/test-copy-acl.sh"
+
+Exit $?
index 147bf564fdceb8407061fae8a4299d1056f29f12..a0a105dac62973aa4c3a6f6aef19550b1b97c69a 100755 (executable)
@@ -41,7 +41,12 @@ func_tmpdir ()
 }
 
 func_tmpdir
-builddir=`pwd`
+# builddir may already be set by the script that invokes this one.
+case "$builddir" in
+  '') builddir=`pwd` ;;
+  /* | ?:*) ;;
+  *) builddir=`pwd`/$builddir ;;
+esac
 cd "$builddir" ||
   {
     echo "$0: cannot determine build directory (unreadable parent dir?)" >&2
index 8998ba5e40efef1b39c346223d50950e8ce06487..c18f5e90d94630aa54d87ebd6d18b050c0bda37b 100755 (executable)
@@ -3,6 +3,8 @@
 # Test copy-file on the file system of /var/tmp, which usually is a local
 # file system.
 
+. "${srcdir=.}/init.sh"; path_prepend_ .
+
 if test -d /var/tmp; then
   TMPDIR=/var/tmp
 else
@@ -10,11 +12,11 @@ else
 fi
 export TMPDIR
 
-"${srcdir}/test-copy-file.sh"
+$BOURNE_SHELL "${srcdir}/test-copy-file.sh"
 ret1=$?
-NO_STDERR_OUTPUT=1 "${srcdir}/test-copy-file.sh"
+NO_STDERR_OUTPUT=1 $BOURNE_SHELL "${srcdir}/test-copy-file.sh"
 ret2=$?
 case $ret1 in
-  77 ) exit $ret2 ;;
-  * ) exit $ret1 ;;
+  77 ) Exit $ret2 ;;
+  * ) Exit $ret1 ;;
 esac
index 1756f7eb47482a47fa81359ecc54975a5604ac60..d3b7f0e736515ce703d4a39da512fe314e337efd 100755 (executable)
@@ -3,14 +3,16 @@
 # Test copy-file on the file system of the build directory, which may be
 # a local file system or NFS mounted.
 
+. "${srcdir=.}/init.sh"; path_prepend_ .
+
 TMPDIR=`pwd`
 export TMPDIR
 
-"${srcdir}/test-copy-file.sh"
+$BOURNE_SHELL "${srcdir}/test-copy-file.sh"
 ret1=$?
-NO_STDERR_OUTPUT=1 "${srcdir}/test-copy-file.sh"
+NO_STDERR_OUTPUT=1 $BOURNE_SHELL "${srcdir}/test-copy-file.sh"
 ret2=$?
 case $ret1 in
-  77 ) exit $ret2 ;;
-  * ) exit $ret1 ;;
+  77 ) Exit $ret2 ;;
+  * ) Exit $ret1 ;;
 esac
index 98da280efb9c473170bdc1c3dc0b8ee74c5ce2b5..cd2868d243c8894c0315b05a272a6808533eb6a4 100755 (executable)
@@ -35,7 +35,12 @@ func_tmpdir ()
 }
 
 func_tmpdir
-builddir=`pwd`
+# builddir may already be set by the script that invokes this one.
+case "$builddir" in
+  '') builddir=`pwd` ;;
+  /* | ?:*) ;;
+  *) builddir=`pwd`/$builddir ;;
+esac
 cd "$builddir" ||
   {
     echo "$0: cannot determine build directory (unreadable parent dir?)" >&2
index e3ad9c0e8cb5e4b17c84c1de7989078a03298cc4..ab13a88c3ba1eb7e60f6e12c304a2527d9a3f742 100755 (executable)
@@ -3,6 +3,8 @@
 # Test file-has-acl on the file system of /var/tmp, which usually is a local
 # file system.
 
+. "${srcdir=.}/init.sh"; path_prepend_ .
+
 if test -d /var/tmp; then
   TMPDIR=/var/tmp
 else
@@ -10,4 +12,6 @@ else
 fi
 export TMPDIR
 
-exec "${srcdir}/test-file-has-acl.sh"
+$BOURNE_SHELL "${srcdir}/test-file-has-acl.sh"
+
+Exit $?
index 6b92b1d9284f798483f18bbd73bb676b20016b3a..41561d6cf3b828fe3d1175b5ffcd553f1e750fe9 100755 (executable)
@@ -3,7 +3,11 @@
 # Test file-has-acl on the file system of the build directory, which may be
 # a local file system or NFS mounted.
 
+. "${srcdir=.}/init.sh"; path_prepend_ .
+
 TMPDIR=`pwd`
 export TMPDIR
 
-exec "${srcdir}/test-file-has-acl.sh"
+$BOURNE_SHELL "${srcdir}/test-file-has-acl.sh"
+
+Exit $?
index 26610c1e27836ab47d0fb00c789b2c019d150050..a2fa9c3a00de3c54caf5e67cf9a36b0bd8cd7c04 100755 (executable)
@@ -41,7 +41,12 @@ func_tmpdir ()
 }
 
 func_tmpdir
-builddir=`pwd`
+# builddir may already be set by the script that invokes this one.
+case "$builddir" in
+  '') builddir=`pwd` ;;
+  /* | ?:*) ;;
+  *) builddir=`pwd`/$builddir ;;
+esac
 cd "$builddir" ||
   {
     echo "$0: cannot determine build directory (unreadable parent dir?)" >&2
index 68c247cd15d4bf8846d2b8f2f4de362f637e8f1f..7b16b3739bcb8e2e75050f1f6c411d3ee573cb72 100755 (executable)
@@ -3,6 +3,8 @@
 # Test set-mode-acl on the file system of /var/tmp, which usually is a local
 # file system.
 
+. "${srcdir=.}/init.sh"; path_prepend_ .
+
 if test -d /var/tmp; then
   TMPDIR=/var/tmp
 else
@@ -10,4 +12,6 @@ else
 fi
 export TMPDIR
 
-exec "${srcdir}/test-set-mode-acl.sh"
+$BOURNE_SHELL "${srcdir}/test-set-mode-acl.sh"
+
+Exit $?
index d1377dfc8f643f64f8f0e39deae2f467778c20ff..2f7c8c02d5fcdf32dcb77b6508776db577f7702e 100755 (executable)
@@ -3,7 +3,11 @@
 # Test set-mode-acl on the file system of the build directory, which may be
 # a local file system or NFS mounted.
 
+. "${srcdir=.}/init.sh"; path_prepend_ .
+
 TMPDIR=`pwd`
 export TMPDIR
 
-exec "${srcdir}/test-set-mode-acl.sh"
+$BOURNE_SHELL "${srcdir}/test-set-mode-acl.sh"
+
+Exit $?
index f0b1641a430273c47c46a470eb0e09ea8c87e517..b2f12cf2202e46b45686ab8c1a19d6f4d63a5a48 100755 (executable)
@@ -41,7 +41,12 @@ func_tmpdir ()
 }
 
 func_tmpdir
-builddir=`pwd`
+# builddir may already be set by the script that invokes this one.
+case "$builddir" in
+  '') builddir=`pwd` ;;
+  /* | ?:*) ;;
+  *) builddir=`pwd`/$builddir ;;
+esac
 cd "$builddir" ||
   {
     echo "$0: cannot determine build directory (unreadable parent dir?)" >&2
index b4c389c96381cdd9e698cfc0a83d2565cb17f737..9b2efef65251481742dea27fb012b6917832fbac 100755 (executable)
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 : ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ "$abs_aux_dir" .
+. "$srcdir/init.sh"; path_prepend_ .
 
 tmpdir=vc-cvs
 repo=`pwd`/$tmpdir/repo
@@ -44,7 +44,7 @@ for i in with-cvsu without; do
     cvs -Q -d "$repo" import -m imp m M M0 &&
     cvs -Q -d "$repo" co m && cd m &&
     printf '%s\n' b c d/a > expected &&
-    vc-list-files | sort > actual &&
+    $BOURNE_SHELL "$abs_aux_dir/vc-list-files" | sort > actual &&
     compare expected actual &&
     ok=1
   test $ok = 0 && fail=1
index b47105032bac79a6921f4c68a6508d80d7dc3bdb..15db4d0eef47dd53d7466f45bd611ca030a6cfbc 100755 (executable)
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 : ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ "$abs_aux_dir" .
+. "$srcdir/init.sh"; path_prepend_ .
 
 tmpdir=vc-git-$$
 GIT_DIR= GIT_WORK_TREE=; unset GIT_DIR GIT_WORK_TREE
@@ -35,7 +35,7 @@ mkdir $tmpdir && cd $tmpdir &&
   git add . > /dev/null &&
   git commit -q -a -m log &&
   printf '%s\n' b c d/a > expected &&
-  vc-list-files > actual &&
+  $BOURNE_SHELL "$abs_aux_dir/vc-list-files" > actual &&
   compare expected actual &&
   fail=0