Get tests running under -T (cosmetics only)
[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
39dbc69b 12 plan skip_all => "Package::Stash ($INC{'Package/Stash.pm'}) loaded before the test even started >.<"
13 if $INC{'Package/Stash.pm'};
14
666d9c2f 15 eval { require Variable::Magic }
16 or plan skip_all => "PP tests already executed";
17
18 $ENV{B_HOOKS_ENDOFSCOPE_IMPLEMENTATION} = 'PP';
39dbc69b 19 $ENV{PACKAGE_STASH_IMPLEMENTATION} = 'PP';
666d9c2f 20}
21
22use B::Hooks::EndOfScope 0.12;
39dbc69b 23use Package::Stash;
666d9c2f 24
25ok(
26 ($INC{'B/Hooks/EndOfScope/PP.pm'} && ! $INC{'B/Hooks/EndOfScope/XS.pm'}),
27 'PP BHEOS loaded properly'
28) || diag join "\n",
29 map { sprintf '%s => %s', $_, $INC{"B/Hooks/$_"} || 'undef' }
30 qw|EndOfScope.pm EndOfScope/XS.pm EndOfScope/PP.pm|
31;
9887772b 32
39dbc69b 33ok(
34 ($INC{'Package/Stash/PP.pm'} && ! $INC{'Package/Stash/XS.pm'}),
35 'PP Package::Stash loaded properly'
36) || diag join "\n",
37 map { sprintf '%s => %s', $_, $INC{"Package/$_"} || 'undef' }
38 qw|Stash.pm Stash/XS.pm Stash/PP.pm|
39;
40
9887772b 41use Config;
9887772b 42use IPC::Open2 qw(open2);
e6eee479 43use File::Glob 'bsd_glob';
9887772b 44
45# for the $^X-es
46$ENV{PERL5LIB} = join ($Config{path_sep}, @INC);
726710b6 47$ENV{PATH} = '';
9887772b 48
727a1a2f 49
9887772b 50# rerun the tests under the assumption of pure-perl
51my $this_file = quotemeta(__FILE__);
52
726710b6 53for my $fn ( bsd_glob("t/*.t") ) {
9887772b 54 next if $fn =~ /${this_file}$/;
55
726710b6 56 my @cmd = map { $_ =~ /(.+)/ } ($^X, $fn);
9887772b 57
58 # this is cheating, and may even hang here and there (testing on windows passed fine)
59 # if it does - will have to fix it somehow (really *REALLY* don't want to pull
60 # in IPC::Cmd just for a fucking test)
61 # the alternative would be to have an ENV check in each test to force a subtest
62 open2(my $out, my $in, @cmd);
63 while (my $ln = <$out>) {
64 print " $ln";
65 }
66
67 wait;
68 ok (! $?, "Exit $? from: @cmd");
69}
70
71done_testing;