tests setup: less hard-coding of the test subdirectory
authorStefano Lattarini <stefano.lattarini@gmail.com>
Sun, 1 Jul 2012 08:36:34 +0000 (10:36 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Sun, 1 Jul 2012 09:40:21 +0000 (11:40 +0200)
* t/ax/tests-init.sh: Make the code creating the temporary
test subdirectory smart enough to automatically create it
in the same subdirectory of the test that is being run.
* defs-static.in ($MKDIR_P, $am_rel_srcdir): New variables,
AC_SUBST'd from @MKDIR_P@ and @srcdir@ respectively, and
used in the new 'tests-init.sh' code.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
defs-static.in
t/ax/test-init.sh

index 781571ce0bd39e5457598f0e874334351919eae0..133bb960f2473dbc15d77057a68f3c1584cc64bd 100644 (file)
@@ -88,6 +88,7 @@ if test -z "$am_using_tap"; then
   case $argv0 in *.tap) am_using_tap=yes;; *) am_using_tap=no;; esac
 fi
 
+am_rel_srcdir='@srcdir@'
 am_top_srcdir='@abs_srcdir@'
 am_top_builddir='@abs_builddir@'
 testprefix='@prefix@'
@@ -131,6 +132,9 @@ PATH_SEPARATOR='@PATH_SEPARATOR@'
 host_alias=${host_alias-'@host_alias@'}; export host_alias
 build_alias=${build_alias-'@build_alias@'}; export build_alias
 
+# A concurrency-safe "mkdir -p" implementation.
+MKDIR_P=${AM_TESTSUITE_MKDIR_P-'@MKDIR_P@'}
+
 # The shell we use to run our own test scripts, determined at configure
 # time.  It is required in the self tests, and most importantly for the
 # automatic re-execution of test scripts.
index bd511a93976410edd76e2eba87065a6d5b7bde32..d798d6cc57fbda5f84ae7caeb8b74a5e08a55657 100644 (file)
@@ -983,11 +983,14 @@ else
   # temporary/data files.  This will be created shortly, and will be removed
   # by the cleanup trap below if the test passes.  If the test doesn't pass,
   # this directory will be kept, to facilitate debugging.
-  testSubDir=t/$me.dir
+  testSubDir=${argv0#$am_rel_srcdir/}
+  case $testSubDir in
+    */*) testSubDir=${testSubDir%/*}/$me.dir;;
+      *) testSubDir=$me.dir;;
+  esac
   test ! -e $testSubDir || rm_rf_ $testSubDir \
     || framework_failure_ "removing old test subdirectory"
-  test -d t || mkdir t
-  mkdir $testSubDir \
+  $MKDIR_P $testSubDir \
     || framework_failure_ "creating test subdirectory"
   # The leading './' is to avoid CDPATH issues.
   cd ./$testSubDir \