Actually detect errors in pure-perl test
[p5sagit/Devel-GlobalDestruction.git] / t / 01_basic.t
index 8584247..c16cab3 100644 (file)
@@ -1,9 +1,17 @@
 use strict;
 use warnings;
 
-# we need to run a test in GD and this fails
-# use Test::More tests => 3;
-# use ok 'Devel::GlobalDestruction';
+BEGIN {
+    if ($ENV{DEVEL_GLOBALDESTRUCTION_PP_TEST}) {
+        require DynaLoader;
+        no warnings 'redefine';
+        my $orig = \&DynaLoader::bootstrap;
+        *DynaLoader::bootstrap = sub {
+            die 'no XS' if $_[0] eq 'Devel::GlobalDestruction';
+            goto $orig;
+        };
+    }
+}
 
 BEGIN {
     package Test::Scope::Guard;
@@ -13,8 +21,10 @@ BEGIN {
 
 print "1..4\n";
 
+my $had_error = 0;
+END { $? = $had_error };
 sub ok ($$) {
-    print "not " if !$_[0];
+    $had_error++, print "not " if !$_[0];
     print "ok";
     print " - $_[1]" if defined $_[1];
     print "\n";