base compiler detection at example of gcc
[ExtUtils-XBuilder.git] / t / 10_compile.t
blob0b595f18acecc8ff528421877530d9b3f97af0e8
1 #!perl -w
3 use strict;
4 use warnings FATAL => 'all';
6 use Cwd;
7 use File::Spec;
8 use File::Basename;
10 use Test::More;
12 my $dist_basedir =
13   Cwd::abs_path( File::Spec->catdir( File::Basename::dirname($0), File::Spec->updir() ) );
15 my $lib_pl = File::Spec->catfile( $dist_basedir, "t", "lib.pl" );
16 do $lib_pl;
18 my $test_dir = test_dir();
19 my $test_data = test_data();
21 use_ok('ExtUtils::XBuilder');
23 my $builder = ExtUtils::XBuilder->new( output_dir => $test_dir );
25 SKIP: {
26     $builder->has_compiler( TAG => 'C' ) or skip "No C Compiler", 2;
28     my @csources = map { File::Spec->catfile( $test_data, $_ ) } qw(hello_world.c);
29     my @objects = $builder->compile( source => [ @sources ], TAG => 'C' );
30     cmp_ok( scalar(@sources), '==', scalar(@objects), 'compiling hello_world.c' );
31     like( $objects[0], qr/^$test_dir/, 'object directory prefix correct' );
32     my @executables = $builder->link( source => [ @objects ], TAG => 'C', target => 'hello_world' );
33     ...
36 SKIP: {
37     $builder->has_compiler( TAG => 'CXX' ) or skip "No C++ Compiler", 2;
39     my @csources = map { File::Spec->catfile( $test_data, $_ ) } qw(hello_world.cc);
40     my @objects = $builder->compile( source => [ @sources ], TAG => 'CXX' );
41     cmp_ok( scalar(@sources), '==', scalar(@objects), 'compiling hello_world.cc' );
42     like( $objects[0], qr/^$test_dir/, 'object directory prefix correct' );
43     my @executables = $builder->link( source => [ @objects ], TAG => 'CXX', target => 'hello_world' );
44     ...