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