This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Ken pointed out that CBuilder's cleanup is too agrressive
[perl5.git] / lib / ExtUtils / CBuilder / t / 01-basic.t
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 { plan tests => 11 }
15
16 use ExtUtils::CBuilder;
17 use File::Spec;
18 ok 1;
19
20 # TEST doesn't like extraneous output
21 my $quiet = $ENV{PERL_CORE} && !$ENV{HARNESS_ACTIVE};
22
23 my $b = ExtUtils::CBuilder->new(quiet => $quiet);
24 ok $b;
25
26 ok $b->have_compiler;
27
28 my $source_file = File::Spec->catfile('t', 'compilet.c');
29 {
30   local *FH;
31   open FH, "> $source_file" or die "Can't create $source_file: $!";
32   print FH "int boot_compilet(void) { return 1; }\n";
33   close FH;
34 }
35 ok -e $source_file;
36
37 my $object_file = $b->object_file($source_file);
38 ok 1;
39
40 ok $object_file, $b->compile(source => $source_file);
41
42 my $lib_file = $b->lib_file($object_file);
43 ok 1;
44
45 my ($lib, @temps) = $b->link(objects => $object_file,
46                              module_name => 'compilet');
47 $lib =~ tr/"'//d;
48 ok $lib_file, $lib;
49
50 for ($source_file, $lib_file, $object_file) {
51   tr/"'//d;
52   1 while unlink;
53 }
54
55 my @words = $b->split_like_shell(' foo bar');
56 ok @words, 2;
57 ok $words[0], 'foo';
58 ok $words[1], 'bar';