diff --git a/t/Builder.t b/t/Builder.t index 61ab27500..0ef079cef 100644 --- a/t/Builder.t +++ b/t/Builder.t @@ -1,5 +1,12 @@ #!/usr/bin/perl -w +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = '../lib'; + } +} + use Test::Builder; my $Test = Test::Builder->new; diff --git a/t/More.t b/t/More.t index 15ffdaa0b..bee2fb4c8 100644 --- a/t/More.t +++ b/t/More.t @@ -1,5 +1,12 @@ #!perl -w +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = '../lib'; + } +} + use Test::More tests => 37; # Make sure we don't mess with $@ or $!. Test at bottom. diff --git a/t/buffer.t b/t/buffer.t index fe03ca046..6039e4a6f 100644 --- a/t/buffer.t +++ b/t/buffer.t @@ -1,5 +1,12 @@ #!/usr/bin/perl +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = '../lib'; + } +} + # Ensure that intermixed prints to STDOUT and tests come out in the # right order (ie. no buffering problems). diff --git a/t/diag.t b/t/diag.t index 6bb366d3d..0d6769b79 100644 --- a/t/diag.t +++ b/t/diag.t @@ -1,5 +1,12 @@ #!perl -w +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = '../lib'; + } +} + use strict; use Test::More tests => 5; diff --git a/t/exit.t b/t/exit.t index 12a362219..dcc456527 100644 --- a/t/exit.t +++ b/t/exit.t @@ -1,6 +1,13 @@ # Can't use Test.pm, that's a 5.005 thing. package My::Test; +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = '../lib'; + } +} + unless( eval { require File::Spec } ) { print "1..0 # Skip Need File::Spec to run this test\n"; exit 0; @@ -47,7 +54,8 @@ my %Tests = ( print "1..".keys(%Tests)."\n"; -my $lib = File::Spec->catdir(qw(t lib Test Simple sample_tests)); +chdir 't'; +my $lib = File::Spec->catdir(qw(lib Test Simple sample_tests)); while( my($test_name, $exit_codes) = each %Tests ) { my($exit_code) = $exit_codes->[$IsVMS ? 1 : 0]; @@ -63,7 +71,7 @@ while( my($test_name, $exit_codes) = each %Tests ) { } my $file = File::Spec->catfile($lib, $test_name); - my $wait_stat = system(qq{$Perl -"Iblib/lib" $file}); + my $wait_stat = system(qq{$Perl -"I../blib/lib" -"I../lib" -"I../t/lib" $file}); my $actual_exit = $wait_stat >> 8; My::Test::ok( $actual_exit == $exit_code, diff --git a/t/extra.t b/t/extra.t index e3b0510c8..1ed94adb7 100644 --- a/t/extra.t +++ b/t/extra.t @@ -1,5 +1,12 @@ #!perl -w +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = '../lib'; + } +} + # Can't use Test.pm, that's a 5.005 thing. package My::Test; @@ -23,7 +30,8 @@ package main; require Test::Simple; -push @INC, 't/lib/'; +chdir 't'; +push @INC, '../t/lib/'; require Test::Simple::Catch; my($out, $err) = Test::Simple::Catch::caught(); diff --git a/t/fail-like.t b/t/fail-like.t index fa07f06f6..13367633c 100644 --- a/t/fail-like.t +++ b/t/fail-like.t @@ -7,12 +7,20 @@ BEGIN { } } +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = ('../lib', 'lib'); + } + else { + unshift @INC, 't/lib'; + } +} # There was a bug with like() involving a qr// not failing properly. # This tests against that. use strict; -use lib 't/lib'; require Test::Simple::Catch; my($out, $err) = Test::Simple::Catch::caught(); diff --git a/t/fail-more.t b/t/fail-more.t index 1299a5dd2..6fd88c8ee 100644 --- a/t/fail-more.t +++ b/t/fail-more.t @@ -1,7 +1,16 @@ #!perl -w +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = ('../lib', 'lib'); + } + else { + unshift @INC, 't/lib'; + } +} + use strict; -use lib 't/lib'; require Test::Simple::Catch; my($out, $err) = Test::Simple::Catch::caught(); diff --git a/t/fail.t b/t/fail.t index 9a722991a..a041ab0eb 100644 --- a/t/fail.t +++ b/t/fail.t @@ -1,7 +1,16 @@ #!perl -w +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = ('../lib', 'lib'); + } + else { + unshift @INC, 't/lib'; + } +} + use strict; -use lib qw(t/lib); require Test::Simple::Catch; my($out, $err) = Test::Simple::Catch::caught(); diff --git a/t/filehandles.t b/t/filehandles.t index 3b3c553dc..dfea4ba48 100644 --- a/t/filehandles.t +++ b/t/filehandles.t @@ -1,5 +1,12 @@ #!perl -w +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = '../lib'; + } +} + use Test::More tests => 1; tie *STDOUT, "Dev::Null" or die $!; diff --git a/t/import.t b/t/import.t index 468c62fd0..68a36138b 100644 --- a/t/import.t +++ b/t/import.t @@ -1,3 +1,11 @@ +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = '../lib'; + } +} + + use Test::More tests => 2, import => [qw(!fail)]; can_ok(__PACKAGE__, qw(ok pass like isa_ok)); diff --git a/t/is_deeply.t b/t/is_deeply.t index 3fbc4fbbf..5291fb82c 100644 --- a/t/is_deeply.t +++ b/t/is_deeply.t @@ -1,7 +1,16 @@ #!/usr/bin/perl -w +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = ('../lib', 'lib'); + } + else { + unshift @INC, 't/lib'; + } +} + use strict; -use lib qw(t/lib); use Test::Builder; require Test::Simple::Catch; diff --git a/t/missing.t b/t/missing.t index a8861bbbe..7f451804b 100644 --- a/t/missing.t +++ b/t/missing.t @@ -1,3 +1,13 @@ +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = ('../lib', 'lib'); + } + else { + unshift @INC, 't/lib'; + } +} + # Can't use Test.pm, that's a 5.005 thing. package My::Test; @@ -21,7 +31,6 @@ package main; require Test::Simple; -push @INC, 't/lib'; require Test::Simple::Catch; my($out, $err) = Test::Simple::Catch::caught(); diff --git a/t/no_ending.t b/t/no_ending.t index d3ea2756f..97e968e28 100644 --- a/t/no_ending.t +++ b/t/no_ending.t @@ -1,5 +1,12 @@ use Test::Builder; +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = '../lib'; + } +} + BEGIN { my $t = Test::Builder->new; $t->no_ending(1); diff --git a/t/no_header.t b/t/no_header.t index 1acdb0cc7..93e6bec34 100644 --- a/t/no_header.t +++ b/t/no_header.t @@ -1,3 +1,10 @@ +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = '../lib'; + } +} + use Test::Builder; # STDOUT must be unbuffered else our prints might come out after diff --git a/t/no_plan.t b/t/no_plan.t index 4fdca4591..c0af2d464 100644 --- a/t/no_plan.t +++ b/t/no_plan.t @@ -1,3 +1,13 @@ +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = ('../lib', 'lib'); + } + else { + unshift @INC, 't/lib'; + } +} + # Can't use Test.pm, that's a 5.005 thing. package My::Test; @@ -21,7 +31,6 @@ package main; require Test::Simple; -push @INC, 't/lib'; require Test::Simple::Catch; my($out, $err) = Test::Simple::Catch::caught(); diff --git a/t/output.t b/t/output.t index 958ccc706..82dea2883 100644 --- a/t/output.t +++ b/t/output.t @@ -1,6 +1,11 @@ #!perl -w -chdir 't' if -d 't'; +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = '../lib'; + } +} # Can't use Test.pm, that's a 5.005 thing. print "1..3\n"; diff --git a/t/plan.t b/t/plan.t index f2d6785ff..a7b26246a 100644 --- a/t/plan.t +++ b/t/plan.t @@ -1,3 +1,10 @@ +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = '../lib'; + } +} + use Test::More; plan tests => 2; diff --git a/t/plan_is_noplan.t b/t/plan_is_noplan.t index d3587356b..1ab2a0e8b 100644 --- a/t/plan_is_noplan.t +++ b/t/plan_is_noplan.t @@ -1,8 +1,23 @@ +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = ('../lib', 'lib'); + } + else { + unshift @INC, 't/lib'; + } +} + # Can't use Test.pm, that's a 5.005 thing. package My::Test; -# This feature requires a fairly new version of Test::Harness BEGIN { + if( !$ENV{HARNESS_ACTIVE} && $ENV{PERL_CORE} ) { + print "1..0 # Skipped: Won't work with t/TEST\n"; + exit 0; + } + + # This feature requires a fairly new version of Test::Harness require Test::Harness; if( $Test::Harness::VERSION < 1.20 ) { print "1..0 # Skipped: Need Test::Harness 1.20 or up\n"; @@ -30,7 +45,6 @@ package main; require Test::Simple; -push @INC, 't/lib'; require Test::Simple::Catch; my($out, $err) = Test::Simple::Catch::caught(); diff --git a/t/plan_no_plan.t b/t/plan_no_plan.t index ca2978a30..b39b101cc 100644 --- a/t/plan_no_plan.t +++ b/t/plan_no_plan.t @@ -1,5 +1,18 @@ +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = '../lib'; + } +} + use Test::More; +BEGIN { + if( !$ENV{HARNESS_ACTIVE} && $ENV{PERL_CORE} ) { + plan skip_all => "Won't work with t/TEST"; + } +} + BEGIN { require Test::Harness; } diff --git a/t/plan_skip_all.t b/t/plan_skip_all.t index 75f66789a..528df5f50 100644 --- a/t/plan_skip_all.t +++ b/t/plan_skip_all.t @@ -1,3 +1,10 @@ +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = '../lib'; + } +} + use Test::More; plan skip_all => 'Just testing plan & skip_all'; diff --git a/t/simple.t b/t/simple.t index 7f4f1f42d..7297e9d6d 100644 --- a/t/simple.t +++ b/t/simple.t @@ -1,3 +1,10 @@ +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = '../lib'; + } +} + use strict; BEGIN { $| = 1; $^W = 1; } diff --git a/t/skip.t b/t/skip.t index 4de7e7bda..526c5acd8 100644 --- a/t/skip.t +++ b/t/skip.t @@ -1,5 +1,12 @@ #!perl -w +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = '../lib'; + } +} + use Test::More tests => 15; # If we skip with the same name, Test::Harness will report it back and diff --git a/t/skipall.t b/t/skipall.t index c818f4d51..6f255e21c 100644 --- a/t/skipall.t +++ b/t/skipall.t @@ -1,3 +1,13 @@ +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = ('../lib', 'lib'); + } + else { + unshift @INC, 't/lib'; + } +} + use strict; # Can't use Test.pm, that's a 5.005 thing. @@ -22,7 +32,6 @@ sub ok ($;$) { package main; require Test::More; -push @INC, 't/lib'; require Test::Simple::Catch; my($out, $err) = Test::Simple::Catch::caught(); diff --git a/t/todo.t b/t/todo.t index 607fdb945..31ceb5f63 100644 --- a/t/todo.t +++ b/t/todo.t @@ -1,5 +1,12 @@ #!perl -w +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = '../lib'; + } +} + BEGIN { require Test::Harness; use Test::More; diff --git a/t/undef.t b/t/undef.t index 7e5290ffa..525126484 100644 --- a/t/undef.t +++ b/t/undef.t @@ -1,3 +1,10 @@ +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = '../lib'; + } +} + use strict; use Test::More tests => 12; diff --git a/t/use_ok.t b/t/use_ok.t index 17e0c30e7..f1d7bed6b 100644 --- a/t/use_ok.t +++ b/t/use_ok.t @@ -1,3 +1,10 @@ +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = '../lib'; + } +} + use Test::More tests => 7; # Using Symbol because it's core and exports lots of stuff. diff --git a/t/useing.t b/t/useing.t index eadc4b3c3..c4ce50712 100644 --- a/t/useing.t +++ b/t/useing.t @@ -1,3 +1,10 @@ +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = '../lib'; + } +} + use Test::More tests => 5; require_ok('Test::Builder');