Run the PP tests with or without Devek::Hide
[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
fb070db2 11# the PP tests will run either wih D::H (mainly on smokers)
12# or by setting the envvar (for users)
13my $has_d_h = eval { require Devel::Hide };
9887772b 14
15use Config;
16use FindBin qw($Bin);
17use IPC::Open2 qw(open2);
18
19# for the $^X-es
20$ENV{PERL5LIB} = join ($Config{path_sep}, @INC);
21
22# rerun the tests under the assumption of pure-perl
23my $this_file = quotemeta(__FILE__);
24
25for my $fn (glob("$Bin/*.t")) {
26 next if $fn =~ /${this_file}$/;
27
28 local $ENV{DEVEL_HIDE_VERBOSE} = 0;
fb070db2 29 local $ENV{NAMESPACE_CLEAN_USE_PP} = 1 unless $has_d_h;
30 my @cmd = (
31 $^X,
32 $has_d_h ? '-MDevel::Hide=B::Hooks::EndOfScope' : (),
33 $fn
34 );
9887772b 35
36 # this is cheating, and may even hang here and there (testing on windows passed fine)
37 # if it does - will have to fix it somehow (really *REALLY* don't want to pull
38 # in IPC::Cmd just for a fucking test)
39 # the alternative would be to have an ENV check in each test to force a subtest
40 open2(my $out, my $in, @cmd);
41 while (my $ln = <$out>) {
42 print " $ln";
43 }
44
45 wait;
46 ok (! $?, "Exit $? from: @cmd");
47}
48
49done_testing;