This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [PATCH] ExtUtils-{ParseXS,CBuilder} into bleadperl (was: Re: [Module::Build]...
[perl5.git] / lib / ExtUtils / CBuilder / t / 01-basic.t
CommitLineData
6b09c160
YST
1#! perl -w
2
3BEGIN {
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
12use strict;
13use Test;
14BEGIN { plan tests => 11 }
15
16use ExtUtils::CBuilder;
17use File::Spec;
18ok 1;
19
20# TEST doesn't like extraneous output
21my $quiet = $ENV{PERL_CORE} && !$ENV{HARNESS_ACTIVE};
22
23my $b = ExtUtils::CBuilder->new(quiet => $quiet);
24ok $b;
25
26ok $b->have_compiler;
27
28my $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() { return 1; }\n";
33 close FH;
34}
35ok -e $source_file;
36
37my $object_file = $b->object_file($source_file);
38ok 1;
39
40ok $object_file, $b->compile(source => $source_file);
41
42my $lib_file = $b->lib_file($object_file);
43ok 1;
44
45my ($lib, @temps) = $b->link(objects => $object_file,
46 module_name => 'compilet');
47$lib =~ tr/"'//d;
48ok $lib_file, $lib;
49
50for ($source_file, $lib_file, $object_file, @temps) {
51 tr/"'//d;
52 1 while unlink;
53}
54
55my @words = $b->split_like_shell(' foo bar');
56ok @words, 2;
57ok $words[0], 'foo';
58ok $words[1], 'bar';