From c59c8d1536afcd0051cbe23ba538568932ecf00f Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Sun, 1 Jul 2012 10:36:34 +0200 Subject: [PATCH] tests setup: less hard-coding of the test subdirectory * 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 --- defs-static.in | 4 ++++ t/ax/test-init.sh | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/defs-static.in b/defs-static.in index 781571ce0..133bb960f 100644 --- a/defs-static.in +++ b/defs-static.in @@ -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. diff --git a/t/ax/test-init.sh b/t/ax/test-init.sh index bd511a939..d798d6cc5 100644 --- a/t/ax/test-init.sh +++ b/t/ax/test-init.sh @@ -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 \ -- 2.34.1