From: Ian Jackson Date: Thu, 29 Oct 2015 01:17:39 +0000 (+0000) Subject: Testing: Introduce varying CAFTEST_TMP X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=cgi-auth-flexible.git;a=commitdiff_plain;h=3eb1b34dd6160ab9e454feb2648ca3ef52d33eaa Testing: Introduce varying CAFTEST_TMP 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 --- diff --git a/tests/autotest b/tests/autotest index 2fc0986..f2b2870 100755 --- a/tests/autotest +++ b/tests/autotest @@ -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 diff --git a/tests/cgi b/tests/cgi index e59d12a..045ba84 100755 --- 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; diff --git a/tests/wrap b/tests/wrap index c401f57..99df0f9 100755 --- a/tests/wrap +++ b/tests/wrap @@ -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 $!;