X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=ext%2FB%2Ft%2Fo.t;h=2b84f39b29c9d1804b0975b20dd3c60e6bb5d47f;hb=5ce57cc063e43c30cba8f7b560bf201c2c4beb83;hp=6575180ffd52abda860a0d36e4f65a9b9ebd1be3;hpb=d4e33868a5dde8b2762a447652bbf3dc326c19ff;p=p5sagit%2Fp5-mst-13.2.git diff --git a/ext/B/t/o.t b/ext/B/t/o.t index 6575180..2b84f39 100644 --- a/ext/B/t/o.t +++ b/ext/B/t/o.t @@ -1,8 +1,18 @@ #!./perl -w BEGIN { - chdir 't' if -d 't'; - @INC = ('../lib', 'lib', '.'); + if ($ENV{PERL_CORE}){ + chdir('t') if -d 't'; + @INC = ('.', 'lib', '../lib'); + } else { + unshift @INC, 't'; + push @INC, "../../t"; + } + require Config; + if (($Config::Config{'extensions'} !~ /\bB\b/) ){ + print "1..0 # Skip -- Perl configured without B module\n"; + exit 0; + } require 'test.pl'; } @@ -30,10 +40,10 @@ require_ok( 'O' ); my @args = ('-Ilib', '-MO=success,foo,bar', '-e', '1' ); my @lines = get_lines( @args ); -is( $lines[0], '-e syntax OK', 'O.pm should not munge perl output without -qq'); -is( $lines[1], 'Compiling!', 'Output should not be saved without -q switch' ); -is( $lines[2], '(foo) ', 'O.pm should call backend compile() method' ); -is( $lines[3], '[]', 'Nothing should be in $O::BEGIN_output without -q' ); +is( $lines[0], 'Compiling!', 'Output should not be saved without -q switch' ); +is( $lines[1], '(foo) ', 'O.pm should call backend compile() method' ); +is( $lines[2], '[]', 'Nothing should be in $O::BEGIN_output without -q' ); +is( $lines[3], '-e syntax OK', 'O.pm should not munge perl output without -qq'); $args[1] = '-MO=-q,success,foo,bar'; @lines = get_lines( @args ); @@ -42,7 +52,7 @@ isnt( $lines[1], 'Compiling!', 'Output should not be printed with -q switch' ); SKIP: { skip( '-q redirection does not work without PerlIO', 2) unless $Config{useperlio}; - is( $lines[2], "[Compiling!", '... but should be in $O::BEGIN_output' ); + is( $lines[1], "[Compiling!", '... but should be in $O::BEGIN_output' ); $args[1] = '-MO=-qq,success,foo,bar'; @lines = get_lines( @args ); @@ -51,7 +61,7 @@ SKIP: { $args[1] = '-MO=success,fail'; @lines = get_lines( @args ); -like( $lines[0], qr/fail at .eval/, +like( $lines[1], qr/fail at .eval/, 'O.pm should die if backend compile() does not return a subref' ); sub get_lines { @@ -60,11 +70,13 @@ sub get_lines { END { 1 while unlink($file); + rmdir($path); # not "1 while" since there might be more in there } __END__ package B::success; +$| = 1; print "Compiling!\n"; sub compile {