Do not rerun PP tests twice if the envvar is set
[p5sagit/namespace-clean.git] / t / 10-pure-perl.t
CommitLineData
9887772b 1use strict;
2use warnings;
3use Test::More;
4
37f19e68 5plan skip_all => "PP tests already executed"
6 if $ENV{NAMESPACE_CLEAN_USE_PP};
7
9887772b 8eval { require B::Hooks::EndOfScope }
9 or plan skip_all => "PP tests already executed";
10
11eval { require Devel::Hide }
12 or plan skip_all => "Devel::Hide required for this test in presence of B::Hooks::EndOfScope";
13
14use Config;
15use FindBin qw($Bin);
16use IPC::Open2 qw(open2);
17
18# for the $^X-es
19$ENV{PERL5LIB} = join ($Config{path_sep}, @INC);
20
21# rerun the tests under the assumption of pure-perl
22my $this_file = quotemeta(__FILE__);
23
24for my $fn (glob("$Bin/*.t")) {
25 next if $fn =~ /${this_file}$/;
26
27 local $ENV{DEVEL_HIDE_VERBOSE} = 0;
28 my @cmd = ( $^X, '-MDevel::Hide=B::Hooks::EndOfScope', $fn );
29
30 # this is cheating, and may even hang here and there (testing on windows passed fine)
31 # if it does - will have to fix it somehow (really *REALLY* don't want to pull
32 # in IPC::Cmd just for a fucking test)
33 # the alternative would be to have an ENV check in each test to force a subtest
34 open2(my $out, my $in, @cmd);
35 while (my $ln = <$out>) {
36 print " $ln";
37 }
38
39 wait;
40 ok (! $?, "Exit $? from: @cmd");
41}
42
43done_testing;