This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
shared.xs: remove dead code
[perl5.git] / dist / 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);
74d5bfab 7 $perl = qq{"$perl"}; # So it doesn't fail when there are spaces.
9015f106
DG
8}
9
10use strict;
11use Test::More;
9015f106
DG
12BEGIN {
13 if ($^O eq 'VMS') {
14 # So we can get the return value of system()
15 require vmsish;
16 import vmsish;
17 }
18}
19
06e8058f 20plan tests => 7;
9015f106
DG
21
22require_ok "ExtUtils::CBuilder";
23
24my $b = eval { ExtUtils::CBuilder->new(quiet => 1) };
25ok( $b, "got CBuilder object" ) or diag $@;
26
27# test missing compiler
47ce55cb
SH
28{
29my $b1 = ExtUtils::CBuilder->new(quiet => 1);
30configure_fake_missing_compilers($b1);
31is( $b1->have_compiler, 0, "have_compiler: fake missing cc" );
32}
33{
34my $b2 = ExtUtils::CBuilder->new(quiet => 1);
35configure_fake_missing_compilers($b2);
36is( $b2->have_cplusplus, 0, "have_cplusplus: fake missing c++" );
37}
9015f106
DG
38
39# test found compiler
47ce55cb
SH
40{
41my $b3 = ExtUtils::CBuilder->new(quiet => 1);
42configure_fake_present_compilers($b3);
43is( $b3->have_compiler, 1, "have_compiler: fake present cc" );
44}
45{
46my $b4 = ExtUtils::CBuilder->new(quiet => 1);
47configure_fake_present_compilers($b4);
48is( $b4->have_cplusplus, 1, "have_cpp_compiler: fake present c++" );
49}
9015f106 50
506098d4 51# test missing cpp compiler
06e8058f
CBW
52
53# test one non-exported subroutine
54{
55 my $type = ExtUtils::CBuilder::os_type();
56 if ($type) {
57 pass( "OS type $type located for $^O" );
58 }
59 else {
60 pass( "OS type not yet listed for $^O" );
61 }
62}
47ce55cb
SH
63
64sub configure_fake_missing_compilers {
65 my $b = shift;
66 my $bogus_path = 'djaadjfkadjkfajdf';
67 $b->{config}{cc} = $bogus_path;
68 $b->{config}{ld} = $bogus_path;
69 $b->{have_cc} = undef;
70 $b->{have_cxx} = undef;
71}
72
73sub configure_fake_present_compilers {
74 my $b = shift;
75 my $run_perl = "$perl -e1 --";
76 $b->{config}{cc} = $run_perl;
77 $b->{config}{ld} = $run_perl;
78 $b->{config}{cxx} = $run_perl;
79 $b->{have_cc} = undef;
80 $b->{have_cxx} = undef;
81}