From: Michael G. Schwern Date: Sun, 18 Feb 2001 13:44:35 +0000 (-0500) Subject: Adding in TestSetup.pm to replace BEGIN preamble on tests. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4343e7c36e286bd35f0011d180bda3c7612c4aac;p=p5sagit%2Fp5-mst-13.2.git Adding in TestSetup.pm to replace BEGIN preamble on tests. Message-ID: <20010218134435.A17544@magnonel.guild.net> Applied, but as t/TestInit.pm. p4raw-id: //depot/perl@8829 --- diff --git a/MANIFEST b/MANIFEST index 77f921e..4285eba 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1331,6 +1331,7 @@ sv.c Scalar value code sv.h Scalar value header t/README Instructions for regression tests t/TEST The regression tester +t/TestInit.pm Preamble library for core tests t/base/commonsense.t See if configuration meets basic needs t/base/cond.t See if conditionals work t/base/if.t See if if works diff --git a/t/TEST b/t/TEST index acefb54..98d5fe3 100755 --- a/t/TEST +++ b/t/TEST @@ -91,14 +91,16 @@ EOT my $utf = $with_utf ? '-I../lib -Mutf8' : ''; + my $testswitch = '-I. -MTestInit'; # -T will strict . from @INC if ($type eq 'perl') { - my $run = "./perl$switch $utf $test |"; + my $run = "./perl $testswitch $switch $utf $test |"; open(RESULTS,$run) or print "can't run '$run': $!.\n"; } else { my $compile = - "./perl -I../lib ../utils/perlcc -o ./$test.plc $utf ./$test " - ." && ./$test.plc |"; + "./perl $testswitch -I../lib ../utils/perlcc -o ". + "./$test.plc $utf ./$test ". + " && ./$test.plc |"; open(RESULTS, $compile) or print "can't compile '$compile': $!.\n"; unlink "./$test.plc"; diff --git a/t/TestInit.pm b/t/TestInit.pm new file mode 100644 index 0000000..873c3ce --- /dev/null +++ b/t/TestInit.pm @@ -0,0 +1,17 @@ +# This is a replacement for the old BEGIN preamble which heads (or +# should head) up every core test program to prep it for running. +# Now instead of: +# +# BEGIN { +# chdir 't' if -d 't'; +# @INC = '../lib'; +# } +# +# t/TEST will use -MTestInit. It also doesn't hurt if you "use TestInit" +# (not require) in the test scripts. +# +# PS this is not POD because this should be a very minimalist module in +# case of fundemental perl breakage. + +chdir 't' if -d 't'; +@INC = '../lib'; diff --git a/t/op/eval.t b/t/op/eval.t index 1838923..11fbfd0 100755 --- a/t/op/eval.t +++ b/t/op/eval.t @@ -37,7 +37,7 @@ open(try,'>Op.eval'); print try 'print "ok 10\n"; unlink "Op.eval";',"\n"; close try; -do 'Op.eval'; print $@; +do './Op.eval'; print $@; # Test the singlequoted eval optimizer diff --git a/t/op/regexp_noamp.t b/t/op/regexp_noamp.t index 03c19e9..088bd40 100755 --- a/t/op/regexp_noamp.t +++ b/t/op/regexp_noamp.t @@ -3,7 +3,7 @@ $skip_amp = 1; for $file ('op/regexp.t', 't/op/regexp.t') { if (-r $file) { - do $file; + do "./$file"; exit; } } diff --git a/t/op/subst_wamp.t b/t/op/subst_wamp.t index b716b30..ced5ee9 100755 --- a/t/op/subst_wamp.t +++ b/t/op/subst_wamp.t @@ -3,7 +3,7 @@ $dummy = defined $&; # Now we have it... for $file ('op/subst.t', 't/op/subst.t') { if (-r $file) { - do $file; + do "./$file"; exit; } }