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 2fc0986..f2b2870 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 e59d12a..045ba84 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 c401f57..99df0f9 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 $!;