chiark / gitweb /
Testing: Introduce varying CAFTEST_TMP
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 29 Oct 2015 01:17:39 +0000 (01:17 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 1 Nov 2015 21:08:39 +0000 (21:08 +0000)
This defaults to tests/tmp, but we set it in autotest to a
test-specific value.  We are going to use make to do parallel test
running, so they all need their own logfile.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
tests/autotest
tests/cgi
tests/wrap

index 2fc09861f54d641339e013b57e9c0169391810d9..f2b2870665fcc91a70234744b76df552331ba6d2 100755 (executable)
@@ -2,15 +2,24 @@
 
 set testfile [lindex $argv 0]
 
-set tt tests/tmp
+switch -glob -- $testfile {
+    tests/*.at {
+       regsub {^tests/} $testfile {tests/tmp/} tt
+       regsub {\.at$} $tt {} tt
+    }
+    * {
+       set tt tests/tmp/[info pid]
+    }
+}
 
 exec rm -rf $tt
-exec mkdir $tt
+file mkdir tests/tmp $tt
 
 set pwd [pwd]
 
 set env(HOME) $tt
 set env(CAFTEST_CAF) $pwd
+set env(CAFTEST_TMP) $pwd/$tt
 set env(TERM) vt100
 set env(CAFTEST_NOSRCDUMP) 1
 set env(LC_ALL) en_GB.utf-8
index e59d12ab97eb387b5569b8c67b9e97dcb39ece53..045ba847ffdf7817ae0eb7ffa3d697d7cbea6b84 100755 (executable)
--- a/tests/cgi
+++ b/tests/cgi
@@ -10,7 +10,7 @@ use Data::Dumper;
 #use Carp::Always;
 $SIG{__DIE__} = sub { Carp::confess(@_) };
 
-my $dump = "$ENV{'CAFTEST_CAF'}/tests/tmp";
+my $dump = $ENV{'CAFTEST_TMP'} // 'tests/tmp';
 
 my $q = CGI->new;
 
index c401f5738b5c8062637cb6a4543a288684922d77..99df0f904c5fc5c03c76089af00dcc01ccef9267 100755 (executable)
@@ -1,13 +1,15 @@
 #!/bin/sh
 set -e
 cd "$CAFTEST_CAF"
-exec 2>>tests/tmp/wrap.log
-export HTTP_COOKIE=$(cat "tests/tmp/cookie")
+: ${CAFTEST_TMP:=tests/tmp}
+export CAFTEST_TMP
+exec 2>>$CAFTEST_TMP/wrap.log
+export HTTP_COOKIE=$(cat "$CAFTEST_TMP/cookie")
 export CAFTEST_URLBASE=file:///
 tests/cgi "$@" | perl -pe '
     next if m/^$/..0;
     next unless m/Set-Cookie: (\w+=[^; ]+)/;
-    my $cf = "tests/tmp/cookie";
+    my $cf = "$ENV{CAFTEST_TMP}/cookie";
     open C, ">", "$cf.new" or die "$cf $!";
     print C $1 or die $!;
     close C or die $!;