Make sure we work from space-containing paths
[p5sagit/Devel-GlobalDestruction.git] / t / 10_pure-perl.t
1 use strict;
2 use warnings;
3 use FindBin qw($Bin);
4 use Config;
5 use IPC::Open2;
6 use File::Glob 'bsd_glob'; # support spaces in names unlike glob()
7
8 # rerun the tests under the assumption of pure-perl
9
10 # for the $^X-es
11 $ENV{PERL5LIB} = join ($Config{path_sep}, @INC);
12 $ENV{DEVEL_GLOBALDESTRUCTION_PP_TEST} = 1;
13
14 my $this_file = quotemeta(__FILE__);
15
16 my @tests = grep { $_ !~ /${this_file}$/ } bsd_glob("$Bin/*.t");
17 print "1..@{[ scalar @tests ]}\n";
18
19 sub ok ($$) {
20   print "not " if !$_[0];
21   print "ok";
22   print " - $_[1]" if defined $_[1];
23   print "\n";
24 }
25
26 for my $fn (@tests) {
27   # this is cheating, and may even hang here and there (testing on windows passed fine)
28   # if it does - will have to fix it somehow (really *REALLY* don't want to pull
29   # in IPC::Cmd just for a fucking test)
30   # the alternative would be to have an ENV check in each test to force a subtest
31   open2(my $out, my $in, $^X, $fn );
32   while (my $ln = <$out>) {
33     print "   $ln";
34   }
35
36   wait;
37   ok (! $?, "Exit $? from: $^X $fn");
38 }
39