use File::Compare qw(compare);
@ISA = qw(Exporter);
-($VERSION = '$Revision: 1.1 $ ') =~ tr/[0-9].//cd;
+($VERSION = '$Revision: 1.2 $ ') =~ tr/[0-9].//cd;
@EXPORT = qw (run_tests);
-my @Types = qw (IN OUT ERR EXIT);
+my @Types = qw (IN OUT ERR EXIT PRE POST);
my %Types = map {$_ => 1} @Types;
-my %Zero_one_type = map {$_ => 1} qw (OUT ERR EXIT);
+my %Zero_one_type = map {$_ => 1} qw (OUT ERR EXIT PRE POST);
my $srcdir = $ENV{srcdir};
my $Global_count = 1;
{
my $test_name = shift @$t;
my $expect = {};
+ my ($pre, $post);
# FIXME: maybe don't reset this.
$Global_count = 1;
die "$program_name: $test_name: more than one $type spec\n"
if $Zero_one_type{$type} and $seen_type{$type}++;
+ if ($type eq 'PRE' or $type eq 'POST')
+ {
+ $expect->{$type} = $val;
+ next;
+ }
+
if ($type eq 'EXIT')
{
die "$program_name: $test_name: invalid EXIT code\n"
# in OUT or ERR spec?
warn "$test_name...\n" if $verbose;
+ &{$expect->{PRE}} if $expect->{PRE};
my %tmp;
$tmp{OUT} = "$test_name-out";
$tmp{ERR} = "$test_name-err";
warn "$program_name: test $test_name failed: command failed:\n"
. " `$cmd_str': $!\n";
$fail = 1;
- next;
+ goto cleanup;
}
$rc >>= 8 if $rc > 0x80;
if ($expect->{EXIT} != $rc)
warn "$program_name: test $test_name failed: exit status mismatch:"
. " expected $expect->{EXIT}, got $rc\n";
$fail = 1;
- next;
+ goto cleanup;
}
foreach $eo (qw (OUT ERR))
$fail = 1;
}
}
+
+ cleanup:
+ &{$expect->{POST}} if $expect->{POST};
+
}
# FIXME: maybe unlink files inside the big foreach loop?