Reorganize PP test to fail comprehensibly on failed prereqs
[p5sagit/namespace-clean.git] / t / 10-pure-perl.t
CommitLineData
9887772b 1use strict;
2use warnings;
3use Test::More;
4
666d9c2f 5BEGIN {
6 plan skip_all => "PP tests already executed"
7 if $ENV{NAMESPACE_CLEAN_USE_PP};
37f19e68 8
666d9c2f 9 plan skip_all => "B::Hooks::EndOfScope ($INC{'B/Hooks/EndOfScope.pm'}) loaded before the test even started >.<"
10 if $INC{'B/Hooks/EndOfScope.pm'};
9887772b 11
666d9c2f 12 eval { require Variable::Magic }
13 or plan skip_all => "PP tests already executed";
14
15 $ENV{B_HOOKS_ENDOFSCOPE_IMPLEMENTATION} = 'PP';
16}
17
18use B::Hooks::EndOfScope 0.12;
19
20ok(
21 ($INC{'B/Hooks/EndOfScope/PP.pm'} && ! $INC{'B/Hooks/EndOfScope/XS.pm'}),
22 'PP BHEOS loaded properly'
23) || diag join "\n",
24 map { sprintf '%s => %s', $_, $INC{"B/Hooks/$_"} || 'undef' }
25 qw|EndOfScope.pm EndOfScope/XS.pm EndOfScope/PP.pm|
26;
9887772b 27
28use Config;
29use FindBin qw($Bin);
30use IPC::Open2 qw(open2);
e6eee479 31use File::Glob 'bsd_glob';
9887772b 32
33# for the $^X-es
34$ENV{PERL5LIB} = join ($Config{path_sep}, @INC);
35
727a1a2f 36
9887772b 37# rerun the tests under the assumption of pure-perl
38my $this_file = quotemeta(__FILE__);
39
e6eee479 40for my $fn (bsd_glob("$Bin/*.t")) {
9887772b 41 next if $fn =~ /${this_file}$/;
42
727a1a2f 43 my @cmd = ($^X, $fn);
9887772b 44
45 # this is cheating, and may even hang here and there (testing on windows passed fine)
46 # if it does - will have to fix it somehow (really *REALLY* don't want to pull
47 # in IPC::Cmd just for a fucking test)
48 # the alternative would be to have an ENV check in each test to force a subtest
49 open2(my $out, my $in, @cmd);
50 while (my $ln = <$out>) {
51 print " $ln";
52 }
53
54 wait;
55 ok (! $?, "Exit $? from: @cmd");
56}
57
58done_testing;