t/pod/testpods/lib/Pod/Stuff.pm Sample data for find.t
t/README Instructions for regression tests
t/run/exit.t Test perl's exit status.
-t/run/kill_perl.t Tests that kill perl.
+t/run/fresh_perl.t Tests that require a fresh perl.
t/run/noswitch.t Test aliasing ARGV for other switch tests
t/run/runenv.t Test if perl honors its environment variables.
t/run/switcha.t Test the -a switch
# ** DO NOT ADD ANY MORE TESTS HERE **
# Instead, put the test in the appropriate test file and use the
-# kill_perl() function in t/test.pl.
+# fresh_perl_is()/fresh_perl_like() functions in t/test.pl.
# This is for tests that will normally cause segfaults, and other nasty
# errors that might kill the interpreter and for some reason you can't
my($prog,$expected) = split(/\nEXPECT\n/, $raw_prog);
- kill_perl($prog, $expected, { switches => [$switch] }, $name);
+ $expected =~ s/\n+$//;
+
+ fresh_perl_is($prog, $expected, { switches => [$switch] }, $name);
}
__END__
EXPECT
ok
########
-open(H,'run/kill_perl.t'); # must be in the 't' directory
+open(H,'run/fresh_perl.t'); # must be in the 't' directory
stat(H);
print "ok\n" if (-e _ and -f _ and -r _);
EXPECT
1 while -f ++$tmpfile;
END { unlink_all $tmpfile }
-sub kill_perl {
- my($prog, $expected, $runperl_args, $name) = @_;
+#
+# _fresh_perl
+#
+# The $resolve must be a subref that tests the first argument
+# for success, or returns the definition of success (e.g. the
+# expected scalar) if given no arguments.
+#
+
+sub _fresh_perl {
+ my($prog, $resolve, $runperl_args, $name) = @_;
$runperl_args ||= {};
$runperl_args->{progfile} = $tmpfile;
$results =~ s/\n\n/\n/g;
}
- $expected =~ s/\n+$//;
-
- my $pass = $results eq $expected;
+ my $pass = $resolve->($results);
unless ($pass) {
print STDERR "# PROG: $switch\n$prog\n";
- print STDERR "# EXPECTED:\n$expected\n";
+ print STDERR "# EXPECTED:\n", $resolve->(), "\n";
print STDERR "# GOT:\n$results\n";
print STDERR "# STATUS: $status\n";
}
($name) = $prog =~ /^(.{1,35})/ unless $name;
- _ok($pass, _where(), "kill_perl - $name");
+ _ok($pass, _where(), "fresh_perl - $name");
+}
+
+#
+# run_perl_is
+#
+# Combination of run_perl() and is().
+#
+
+sub fresh_perl_is {
+ my($prog, $expected, $runperl_args, $name) = @_;
+ _fresh_perl($prog,
+ sub { @_ ? $_[0] eq $expected : $expected },
+ $runperl_args, $name);
+}
+
+#
+# run_perl_like
+#
+# Combination of run_perl() and like().
+#
+
+sub fresh_perl_like {
+ my($prog, $expected, $runperl_args, $name) = @_;
+ _fresh_perl($prog,
+ sub { @_ ?
+ $_[0] =~ (ref $expected ? $expected : /$expected/) :
+ $expected },
+ $runperl_args, $name);
}
1;