diff options
author | Nicholas Clark <nick@ccl4.org> | 2021-09-14 09:17:06 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2021-09-16 13:22:06 +0000 |
commit | 9038fafc024d2d25fc1aa7f9c38d1e2ede35ce5c (patch) | |
tree | 432740be8ddc714bd27b94dce526256d9de2246e /ext/B/t | |
parent | 9529cd5ee3952d3ee21874e75246f2b0afdbc756 (diff) | |
download | perl-9038fafc024d2d25fc1aa7f9c38d1e2ede35ce5c.tar.gz |
ext/B/t/o.t shouldn't generate the same test module each run.
Extract its test module B::success into a real file, and eliminate lots
of runtime path creation, file creation and file deletion complexity.
Diffstat (limited to 'ext/B/t')
-rw-r--r-- | ext/B/t/B/success.pm | 13 | ||||
-rw-r--r-- | ext/B/t/o.t | 36 |
2 files changed, 15 insertions, 34 deletions
diff --git a/ext/B/t/B/success.pm b/ext/B/t/B/success.pm new file mode 100644 index 0000000000..0a0c193ff6 --- /dev/null +++ b/ext/B/t/B/success.pm @@ -0,0 +1,13 @@ +package B::success; +use strict; + +$| = 1; +print "Compiling!\n"; + +sub compile { + return 'fail' if ($_[0] eq 'fail'); + print "($_[0]) <$_[1]>\n"; + return sub { print "[$O::BEGIN_output]\n" }; +} + +1; diff --git a/ext/B/t/o.t b/ext/B/t/o.t index b11aa4ac7e..c6207835a1 100644 --- a/ext/B/t/o.t +++ b/ext/B/t/o.t @@ -11,19 +11,6 @@ BEGIN { } use strict; -use File::Spec; -use File::Path; - -my $path = File::Spec->catdir( 'lib', 'B' ); -unless (-d $path) { - mkpath( $path ) or skip_all( 'Cannot create fake module path' ); -} - -my $file = File::Spec->catfile( $path, 'success.pm' ); -local *OUT; -open(OUT, '>', $file) or skip_all( 'Cannot write fake backend module'); -print OUT while <DATA>; -close *OUT; plan( 9 ); # And someone's responsible. @@ -51,25 +38,6 @@ like( $lines[1], qr/fail at .eval/, sub get_lines { my $compile = shift; - split(/[\r\n]+/, runperl( switches => [ '-Ilib', $compile ], - prog => 1, stderr => 1 )); -} - -END { - 1 while unlink($file); - rmdir($path); # not "1 while" since there might be more in there + split(/[\r\n]+/, runperl( switches => [ '-Ilib', '-It', $compile ], + prog => 1, stderr => 1 )); } - -__END__ -package B::success; - -$| = 1; -print "Compiling!\n"; - -sub compile { - return 'fail' if ($_[0] eq 'fail'); - print "($_[0]) <$_[1]>\n"; - return sub { print "[$O::BEGIN_output]\n" }; -} - -1; |