Get tests running under -T (cosmetics only)
[p5sagit/namespace-clean.git] / t / 10-pure-perl.t
index 825a899..2426afb 100644 (file)
@@ -2,36 +2,58 @@ use strict;
 use warnings;
 use Test::More;
 
-plan skip_all => "PP tests already executed"
-  if $ENV{NAMESPACE_CLEAN_USE_PP};
+BEGIN {
+  plan skip_all => "PP tests already executed"
+    if $ENV{NAMESPACE_CLEAN_USE_PP};
 
-eval { require B::Hooks::EndOfScope }
-  or plan skip_all => "PP tests already executed";
+  plan skip_all => "B::Hooks::EndOfScope ($INC{'B/Hooks/EndOfScope.pm'}) loaded before the test even started >.<"
+    if $INC{'B/Hooks/EndOfScope.pm'};
 
-# the PP tests will run either wih D::H (mainly on smokers)
-# or by setting the envvar (for users)
-my $has_d_h = eval { require Devel::Hide };
+  plan skip_all => "Package::Stash ($INC{'Package/Stash.pm'}) loaded before the test even started >.<"
+    if $INC{'Package/Stash.pm'};
+
+  eval { require Variable::Magic }
+    or plan skip_all => "PP tests already executed";
+
+  $ENV{B_HOOKS_ENDOFSCOPE_IMPLEMENTATION} = 'PP';
+  $ENV{PACKAGE_STASH_IMPLEMENTATION} = 'PP';
+}
+
+use B::Hooks::EndOfScope 0.12;
+use Package::Stash;
+
+ok(
+  ($INC{'B/Hooks/EndOfScope/PP.pm'} && ! $INC{'B/Hooks/EndOfScope/XS.pm'}),
+  'PP BHEOS loaded properly'
+) || diag join "\n",
+  map { sprintf '%s => %s', $_, $INC{"B/Hooks/$_"} || 'undef' }
+  qw|EndOfScope.pm EndOfScope/XS.pm EndOfScope/PP.pm|
+;
+
+ok(
+  ($INC{'Package/Stash/PP.pm'} && ! $INC{'Package/Stash/XS.pm'}),
+  'PP Package::Stash loaded properly'
+) || diag join "\n",
+  map { sprintf '%s => %s', $_, $INC{"Package/$_"} || 'undef' }
+  qw|Stash.pm Stash/XS.pm Stash/PP.pm|
+;
 
 use Config;
-use FindBin qw($Bin);
 use IPC::Open2 qw(open2);
+use File::Glob 'bsd_glob';
 
 # for the $^X-es
 $ENV{PERL5LIB} = join ($Config{path_sep}, @INC);
+$ENV{PATH} = '';
+
 
 # rerun the tests under the assumption of pure-perl
 my $this_file = quotemeta(__FILE__);
 
-for my $fn (glob("$Bin/*.t")) {
+for my $fn ( bsd_glob("t/*.t") ) {
   next if $fn =~ /${this_file}$/;
 
-  local $ENV{DEVEL_HIDE_VERBOSE} = 0;
-  local $ENV{NAMESPACE_CLEAN_USE_PP} = 1 unless $has_d_h;
-  my @cmd = (
-    $^X,
-    $has_d_h ? '-MDevel::Hide=B::Hooks::EndOfScope' : (),
-    $fn
-  );
+  my @cmd = map { $_ =~ /(.+)/ } ($^X, $fn);
 
   # this is cheating, and may even hang here and there (testing on windows passed fine)
   # if it does - will have to fix it somehow (really *REALLY* don't want to pull