X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fblosxom.git;a=blobdiff_plain;f=t%2Fdriver.t;fp=t%2Fdriver.t;h=7e12204cf666c4be5684da0774360d961545af59;hp=0000000000000000000000000000000000000000;hb=01cb97d37f6138597c4bc61911241ad4ab500727;hpb=edb54ed7d5e10af1809cc06ef469e9af82e0c52f diff --git a/t/driver.t b/t/driver.t new file mode 100755 index 0000000..7e12204 --- /dev/null +++ b/t/driver.t @@ -0,0 +1,61 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More qw( no_plan ); + +use File::Copy; +use File::Compare; +use Cwd; +use YAML; + + +my $orig_cwd = cwd(); + +opendir(my $dh, $orig_cwd) or die("Opendir failed: $!"); + +my @tests = grep { /^t-/ } readdir $dh; + +for my $testdir (@tests) { + my (undef, $test) = split /-/, $testdir, 2; + + chdir $testdir; + my $cwd = cwd(); + + my $spec = YAML::LoadFile ("spec.yaml"); + + if (! $spec) { + fail ("$test - loading spec"); + next; + } + + my $success = 1; + + copy("../../blosxom.cgi", ".") or die("Copy failed: $!"); + chmod(0777, "blosxom.cgi"); + + system("perl -pi -e 's{/Library/WebServer/Documents/blosxom}{$cwd/data}' blosxom.cgi") == 0 + or die "$!"; + + for (@{$spec->{tests}}) { + my ($args, $output) = @$_; + + system("./blosxom.cgi $args > ${output}.got") == 0 + or die "$!"; + + if (ok(compare("${output}.got", $output) == 0, + "$test - Got expected output for args [$args]")) { + unlink("${output}.got"); + } else { + $success = 0; + } + } + + if ($success) { + unlink("blosxom.cgi"); + } + + chdir $orig_cwd; +} +