Commit | Line | Data |
6b09c160 |
1 | #! perl -w |
2 | |
3 | BEGIN { |
4 | if ($ENV{PERL_CORE}) { |
5 | chdir 't' if -d 't'; |
6 | chdir '../lib/ExtUtils/CBuilder' |
7 | or die "Can't chdir to lib/ExtUtils/CBuilder: $!"; |
8 | @INC = qw(../..); |
9 | } |
10 | } |
11 | |
12 | use strict; |
13 | use Test; |
14 | BEGIN { |
15 | if ($^O eq 'MSWin32') { |
16 | print "1..0 # Skipped: link_executable() is not implemented yet on Win32\n"; |
17 | exit; |
18 | } |
19 | if ($^O eq 'VMS') { |
20 | # So we can get the return value of system() |
21 | require vmsish; |
22 | import vmsish; |
23 | } |
24 | plan tests => 5; |
25 | } |
26 | |
27 | use ExtUtils::CBuilder; |
28 | use File::Spec; |
29 | |
30 | # TEST doesn't like extraneous output |
31 | my $quiet = $ENV{PERL_CORE} && !$ENV{HARNESS_ACTIVE}; |
32 | |
33 | my $b = ExtUtils::CBuilder->new(quiet => $quiet); |
34 | ok $b; |
35 | |
36 | my $source_file = File::Spec->catfile('t', 'compilet.c'); |
37 | { |
38 | local *FH; |
39 | open FH, "> $source_file" or die "Can't create $source_file: $!"; |
40 | print FH "int main(void) { return 11; }\n"; |
41 | close FH; |
42 | } |
43 | ok -e $source_file; |
44 | |
45 | # Compile |
46 | my $object_file; |
47 | ok $object_file = $b->compile(source => $source_file); |
48 | |
49 | # Link |
50 | my ($exe_file, @temps); |
51 | ($exe_file, @temps) = $b->link_executable(objects => $object_file); |
52 | ok $exe_file; |
53 | |
54 | # Try the executable |
55 | ok my_system($exe_file), 11; |
56 | |
57 | # Clean up |
4e96f8e9 |
58 | for ($source_file, $object_file, $exe_file) { |
59 | tr/"'//d; |
60 | 1 while unlink; |
61 | } |
6b09c160 |
62 | |
63 | sub my_system { |
64 | my $cmd = shift; |
65 | if ($^O eq 'VMS') { |
66 | return system("mcr $cmd"); |
67 | } |
68 | return system($cmd) >> 8; |
69 | } |