Require Class::C3::XS if a compiler is available
[gitmo/Class-C3.git] / t / 40_no_xs.t
1 use strict;
2 use warnings;
3 use Test::More;
4
5 BEGIN {
6   plan skip_all => "PP tests not applicable for this perl $]"
7     if $] > 5.009_004;
8
9   plan skip_all => "All tests already executed in PP mode"
10     unless eval { require Class::C3::XS };
11
12   plan skip_all => "Devel::Hide required for this test"
13     unless eval { require Devel::Hide };
14 }
15
16 use Config;
17 use IPC::Open2 qw(open2);
18
19 # for the $^X-es
20 $ENV{PERL5LIB} = join ($Config{path_sep}, @INC);
21
22 # rerun the tests under the assumption of pure-perl
23 my $this_file = quotemeta(__FILE__);
24
25 for my $fn (glob("t/*.t")) {
26   next if $fn =~ /${this_file}$/;
27
28   local $ENV{DEVEL_HIDE_VERBOSE} = 0;
29   my @cmd = (
30     $^X,
31     '-MDevel::Hide=Class::C3::XS',
32     $fn
33   );
34
35   # this is cheating, and may even hang here and there (testing on windows passed fine)
36   # if it does - will have to fix it somehow (really *REALLY* don't want to pull
37   # in IPC::Cmd just for a fucking test)
38   # the alternative would be to have an ENV check in each test to force a subtest
39   open2(my $out, my $in, @cmd);
40   while (my $ln = <$out>) {
41     print "   $ln";
42   }
43
44   wait;
45   ok (! $?, "Exit $? from: @cmd");
46 }
47
48 done_testing;