tests: avoid a spurious failure on MSYS
[platform/upstream/automake.git] / runtest.in
index 0722141..364ba4a 100644 (file)
@@ -1,6 +1,6 @@
 #!@AM_TEST_RUNNER_SHELL@
 #
-# Copyright (C) 2012 Free Software Foundation, Inc.
+# Copyright (C) 2012-2013 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -23,6 +23,39 @@ set -e; set -u
 : ${AM_PROVE_CMD='prove'}
 : ${AM_PROVEFLAGS='--merge --verbose'}
 : ${srcdir='@srcdir@'}
+: ${abs_srcdir='@abs_srcdir@'}
+: ${abs_builddir='@abs_builddir@'}
+: ${PATH_SEPARATOR='@PATH_SEPARATOR@'}
+
+# For sourcing of extra "shell libraries" by our test scripts.  As per
+# POSIX, sourcing a file with '.' will cause it to be looked up in $PATH
+# in case it is given with a relative name containing no slashes.
+if test "$srcdir" != .; then
+  PATH=$abs_srcdir/t/ax$PATH_SEPARATOR$PATH
+fi
+PATH=$abs_builddir/t/ax$PATH_SEPARATOR$PATH
+export PATH
+
+# For use by the testsuite framework.  The Automake test harness
+# define this, so we better do the same.
+export srcdir
+
+# Some testsuite-influential variables should be overridable from the
+# test scripts, but not from the environment.
+# Keep this in sync with the 'Makefile.am:AM_TESTS_ENVIRONMENT'.
+for v in \
+  required \
+  am_test_protocol \
+  am_serial_tests \
+  am_test_prefer_config_shell \
+  am_original_AUTOMAKE \
+  am_original_ACLOCAL \
+  am_test_lib_sourced \
+  test_lib_sourced \
+; do
+  eval "$v= && unset $v" || exit 1
+done
+unset v
 
 error () { echo "$0: $*" >&2; exit 255; }
 
@@ -75,10 +108,10 @@ esac
 
 case $tst in
   *.sh)
-    exec $AM_TEST_RUNNER_SHELL $shell_opts "$tst" "$@" ;;
+    exec $AM_TEST_RUNNER_SHELL $shell_opts "$tst" ${1+"$@"} ;;
   *.tap)
     exec "$AM_PROVE_CMD" $AM_PROVEFLAGS -e \
-         "$AM_TEST_RUNNER_SHELL $shell_opts" "$tst" "$@" ;;
+         "$AM_TEST_RUNNER_SHELL $shell_opts" "$tst" ${1+"$@"} ;;
   *)
     error "test '$tst' has an unrecognized extension" ;;
 esac