Reorganize PP test to fail comprehensibly on failed prereqs
Peter Rabbitson [Sun, 9 Dec 2012 04:30:16 +0000 (05:30 +0100)]
Prompted by http://www.cpantesters.org/cpan/report/33f54a42-3f59-11e2-b03f-503131b64f85

t/10-pure-perl.t

index 704ed30..1bbfd6e 100644 (file)
@@ -2,16 +2,28 @@ 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 Variable::Magic }
-  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'};
 
-$ENV{B_HOOKS_ENDOFSCOPE_IMPLEMENTATION} = 'PP';
-require B::Hooks::EndOfScope;
-ok( ($INC{'B/Hooks/EndOfScope/PP.pm'} && ! $INC{'B/Hooks/EndOfScope/XS.pm'}),
-  'PP BHEOS loaded properly');
+  eval { require Variable::Magic }
+    or plan skip_all => "PP tests already executed";
+
+  $ENV{B_HOOKS_ENDOFSCOPE_IMPLEMENTATION} = 'PP';
+}
+
+use B::Hooks::EndOfScope 0.12;
+
+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|
+;
 
 use Config;
 use FindBin qw($Bin);