Fix minor errors with t/static_basic unit tests.
[matthijs/upstream/blosxom.git] / t / driver
index 574276b1984db8b6c05735ecdf72c016b349bf57..c1e9a555064d26b8ae8fc1d6138d7c53fbd849df 100644 (file)
--- a/t/driver
+++ b/t/driver
@@ -28,8 +28,20 @@ die "cannot find blosxom config dir '$blosxom_config_dir'" unless -d $blosxom_co
 $ENV{BLOSXOM_CONFIG_DIR} = $blosxom_config_dir;
 $ENV{TZ} = 'UTC';
 
-my $blosxom_cgi = "$testdir/../../blosxom.cgi";
-die "cannot find blosxom.cgi '$blosxom_cgi'" unless -f $blosxom_cgi;
+my $blosxom_cgi = $ENV{BLOSXOM_CGI};
+unless ($blosxom_cgi && -f $blosxom_cgi) {
+  if (-f "$testdir/../../blosxom.cgi") {
+    $blosxom_cgi = "$testdir/../../blosxom.cgi";
+    warn "ignoring BLOSXOM_CGI setting '$ENV{BLOSXOM_CGI}' - using '$blosxom_cgi' instead"
+      if $ENV{BLOSXOM_CGI};
+  }
+  elsif ($blosxom_cgi) {
+    die "cannot find blosxom.cgi '$blosxom_cgi' - check your BLOSXOM_CGI environment variable";
+  }
+  else {
+    die "cannot find blosxom.cgi - please set the BLOSXOM_CGI environment variable";
+  }
+}
 die "blosxom.cgi '$blosxom_cgi' is not executable" unless -x $blosxom_cgi;
 
 my $spec = YAML::LoadFile ("$testdir/spec.yaml") 
@@ -57,7 +69,8 @@ if ($static_password) {
     skip "Static tests require 'expected' directory", 1 unless $expected;
     $expected = "$blosxom_config_dir/../$expected" unless $expected =~ m!^/!;
     skip "Static tests 'expected' directory is missing", 1 unless -d $expected;
-    skip "Static tests 'static_dir' directory is missing", 1 unless -d $static_dir;
+    -d $static_dir or mkdir $static_dir
+      or die "mkdir on static_dir '$static_dir' failed: $!";
 
     File::Remove::remove(\1, "$static_dir/*");
 
@@ -68,6 +81,7 @@ if ($static_password) {
       my ($a_short, $b_short) = ($a, $b);
       $a_short =~ s!^.*\.\./!! if $a_short;
       $b_short =~ s!^.*\.\./!! if $b_short;
+      return if $b && $b =~ m! /CVS$ !x;
       if (! $b) {
         fail("$a_short has no corresponding file");
       } elsif (! $a) {
@@ -91,6 +105,9 @@ if ($static_password) {
         eq_or_diff($got, $expected, "file $a_short and $b_short match", { style => 'Unified' });
       }
     }, { ignore_cmp => 1 });
+
+    # Cleanup static output
+    File::Remove::remove(\1, "$static_dir/*") unless $ENV{BLOSXOM_STATIC_NO_CLEANUP};
   }
 }