This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Sync ExtUtils-CBuilder test scripts with CPAN versions
[perl5.git] / cpan / ExtUtils-CBuilder / t / 00-have-compiler.t
1 #! perl -w
2
3 use File::Spec;
4 my $perl;
5 BEGIN {
6   $perl = File::Spec->rel2abs($^X);
7   if ($ENV{PERL_CORE}) {
8     chdir 't' if -d 't';
9     chdir '../lib/ExtUtils/CBuilder'
10       or die "Can't chdir to lib/ExtUtils/CBuilder: $!";
11     @INC = qw(../..);
12   }
13 }
14
15 use strict;
16 use Test::More;
17 BEGIN { 
18   if ($^O eq 'VMS') {
19     # So we can get the return value of system()
20     require vmsish;
21     import vmsish;
22   }
23 }
24
25 plan tests => 4;
26
27 require_ok "ExtUtils::CBuilder";
28
29 my $b = eval { ExtUtils::CBuilder->new(quiet => 1) };
30 ok( $b, "got CBuilder object" ) or diag $@;
31
32 # test missing compiler
33 $b->{config}{cc} = 'djaadjfkadjkfajdf';
34 $b->{config}{ld} = 'djaadjfkadjkfajdf';
35 is( $b->have_compiler, 0, "have_compiler: fake missing cc" );
36
37 # test found compiler
38 $b->{have_compiler} = undef;
39 $b->{config}{cc} = "$perl -e1 --";
40 $b->{config}{ld} = "$perl -e1 --";
41 is( $b->have_compiler, 1, "have_compiler: fake present cc" );
42
43