6 chdir '../lib/ExtUtils/CBuilder'
7 or die "Can't chdir to lib/ExtUtils/CBuilder: $!";
16 # So we can get the return value of system()
21 use ExtUtils::CBuilder;
24 # TEST doesn't like extraneous output
25 my $quiet = $ENV{PERL_CORE} && !$ENV{HARNESS_ACTIVE};
26 my ($source_file, $object_file, $exe_file);
28 my $b = ExtUtils::CBuilder->new(quiet => $quiet);
31 if ($^O eq 'MSWin32') {
32 plan skip_all => "link_executable() is not implemented yet on Win32";
34 elsif ( ! $b->have_compiler ) {
35 plan skip_all => "no compiler available for testing";
41 ok $b, "created EU::CB object";
43 $source_file = File::Spec->catfile('t', 'compilet.c');
46 open FH, "> $source_file" or die "Can't create $source_file: $!";
47 print FH "int main(void) { return 11; }\n";
50 ok -e $source_file, "generated '$source_file'";
53 eval { $object_file = $b->compile(source => $source_file) };
54 is $@, q{}, "no exception from compilation";
55 ok -e $object_file, "found object file";
59 skip "error compiling source", 3
60 unless -e $object_file;
63 eval { ($exe_file, @temps) = $b->link_executable(objects => $object_file) };
64 is $@, q{}, "no exception from linking";
65 ok -e $exe_file, "found executable file";
67 if ($^O eq 'os2') { # Analogue of LDLOADPATH...
68 # Actually, not needed now, since we do not link with the generated DLL
69 my $old = OS2::extLibpath(); # [builtin function]
70 $old = ";$old" if defined $old and length $old;
71 # To pass the sanity check, components must have backslashes...
72 OS2::extLibpath_set(".\\$old");
76 my $ec = my_system($exe_file);
77 is $ec, 11, "got expected exit code from executable"
78 or print( $? == -1 ? "# Could not run '$exe_file'\n"
79 : "# Unexpected exit code '$ec'\n");
83 for ($source_file, $object_file, $exe_file) {
89 1 while unlink 'COMPILET.LIS';
90 1 while unlink 'COMPILET.OPT';
96 return system("mcr $cmd");
98 return system($cmd) >> 8;