t/TEST shouldn't use -M options until we've tested that they work.
[p5sagit/p5-mst-13.2.git] / t / TestInit.pm
index a932286..637cfec 100644 (file)
@@ -1,5 +1,5 @@
 # This is a replacement for the old BEGIN preamble which heads (or
-# should head) up every core test program to prep it for running.  
+# should head) up every core test program to prepare it for running.
 # Now instead of:
 #
 # BEGIN {
@@ -7,14 +7,33 @@
 #   @INC = '../lib';
 # }
 #
-# t/TEST will use -MTestInit.  It also doesn't hurt if you "use TestInit"
-# (not require) in the test scripts.
+# Its primary purpose is to clear @INC so core tests don't pick up
+# modules from an installed Perl.
 #
-# PS this is not POD because this should be a very minimalist module in
-# case of fundemental perl breakage.
+# t/TEST will use -MTestInit.  You may "use TestInit" in the test
+# programs but it is not required.
+#
+# P.S. This documentation is not in POD format in order to avoid
+# problems when there are fundamental bugs in perl.
+
+package TestInit;
+
+$VERSION = 1.02;
+
+chdir 't' if -f 't/TestInit.pm';
+
+# Let tests know they're running in the perl core.  Useful for modules
+# which live dual lives on CPAN.
+# Don't interfere with the taintedness of %ENV, this could perturbate tests.
+# This feels like a better solution than the original, from
+# http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2003-07/msg00154.html
+$ENV{PERL_CORE} = $^X;
+if (${^TAINT}) {
+    @INC = '../lib';
+} else {
+    @INC = ('../lib', '.');
+}
 
-chdir 't' if -d 't';
-@INC = '../lib';
-$0 =~ s/\.dp$//;
+$0 =~ s/\.dp$//; # for the test.deparse make target
 1;