tests: avoid spurious failures under "make distcheck"
authorStefano Lattarini <stefano.lattarini@gmail.com>
Wed, 22 Feb 2012 11:30:38 +0000 (12:30 +0100)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Wed, 22 Feb 2012 12:31:31 +0000 (13:31 +0100)
* tests/tap-setup.sh: Pass also '-f' option to 'cp' invocations,
so that files that have already been copied in without write
permissions will still be overwritten where needed, instead of
causing a spurious testsuite failure.  Issue seen when the
testsuite is run under "distcheck".
* tests/defs (get_shell_script): Remove target file before
overwriting it, for the same reason.  Rework code flow a bit
since we are at it.

tests/defs
tests/tap-setup.sh

index 98bc8e1..fd0a8ad 100644 (file)
@@ -612,11 +612,13 @@ sed_unindent_prog="" # Avoid interferences from the environment.
 # of /bin/sh.
 get_shell_script ()
 {
+  test ! -f "$1" || rm -f "$1" || return 99
   if test x"$am_test_prefer_config_shell" = x"yes"; then
-    sed "1s|#!.*|#! $SHELL|" "$am_scriptdir/$1" > "$1"
-    chmod a+x "$1"
+    sed "1s|#!.*|#! $SHELL|" "$am_scriptdir/$1" > "$1" \
+     && chmod a+x "$1" \
+     || return 99
   else
-    cp "$am_scriptdir/$1" .
+    cp -f "$am_scriptdir/$1" . || return 99
   fi
   sed 10q "$1" # For debugging.
 }
index ee9d814..6b69a53 100755 (executable)
@@ -28,7 +28,7 @@ test -f ../defs-static && test -f ../defs \
 test ! -f Makefile.am || mv Makefile.am Makefile.am~ \
   || fatal_ "failed to save Makefile.am"
 
-test -d ../tap-common-setup.dir && cp -Rp ../tap-common-setup.dir/* . \
+test -d ../tap-common-setup.dir && cp -fpR ../tap-common-setup.dir/* . \
   || fatal_ "couldn't get precomputed data files"
 
 fetch_tap_driver