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 | |
d1cf867f |
54 | if ($^O eq 'os2') { # Analogue of LDLOADPATH... |
55 | # Actually, not needed now, since we do not link with the generated DLL |
56 | my $old = OS2::extLibpath(); # [builtin function] |
57 | $old = ";$old" if defined $old and length $old; |
58 | # To pass the sanity check, components must have backslashes... |
59 | OS2::extLibpath_set(".\\$old"); |
60 | } |
61 | |
6b09c160 |
62 | # Try the executable |
63 | ok my_system($exe_file), 11; |
64 | |
65 | # Clean up |
4e96f8e9 |
66 | for ($source_file, $object_file, $exe_file) { |
67 | tr/"'//d; |
68 | 1 while unlink; |
69 | } |
6b09c160 |
70 | |
71 | sub my_system { |
72 | my $cmd = shift; |
73 | if ($^O eq 'VMS') { |
74 | return system("mcr $cmd"); |
75 | } |
76 | return system($cmd) >> 8; |
77 | } |