File: 04module_build.t

package info (click to toggle)
libextutils-cchecker-perl 0.11-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 176 kB
  • sloc: perl: 353; makefile: 2
file content (60 lines) | stat: -rw-r--r-- 1,803 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/perl

use v5;
use strict;
use warnings;

use Test::More;

use ExtUtils::CChecker;

my $cc = ExtUtils::CChecker->new;

# Module::Build tries dist_version_from() from lib/ExtUtils/CChecker.pm
# when called just with module_name()
my $dist_version = $ExtUtils::CChecker::VERSION;

# default configuration
{
   my $build = $cc->new_module_build( module_name => "ExtUtils::CChecker", dist_version => $dist_version );

   isa_ok( $build, "Module::Build", '$build' );

   is( $build->module_name, "ExtUtils::CChecker", '$build->module_name in default config' );
}

$cc->push_include_dirs( "/usr/include/foo" );
$cc->push_extra_compiler_flags( "-DHAVE_FOO" );
$cc->push_extra_linker_flags( "-lfoo" );

# stored configuration
{
   my $build = $cc->new_module_build( module_name => "ExtUtils::CChecker", dist_version => $dist_version );

   is_deeply( $build->include_dirs,         [ "/usr/include/foo" ],
      '$build->include_dirs' );
   is_deeply( $build->extra_compiler_flags, [ "-DHAVE_FOO" ],
      '$build->extra_compiler_flags' );
   is_deeply( $build->extra_linker_flags,   [ "-lfoo" ],
      '$build->extra_linker_flags' );
}

# merged configuration
{
   my $build = $cc->new_module_build( 
      module_name => "ExtUtils::CChecker",
      dist_version => $dist_version,
      include_dirs => [ "/usr/include/bar" ],
      extra_compiler_flags => [ "-DHAVE_BAR" ],
      extra_linker_flags => [ "-lbar" ],
   );

   is_deeply( $build->include_dirs,         [ "/usr/include/foo", "/usr/include/bar" ],
      '$build->include_dirs merged ');
   is_deeply( $build->extra_compiler_flags, [ "-DHAVE_FOO", "-DHAVE_BAR" ],
      '$build->extra_compiler_flags merged' );
   is_deeply( $build->extra_linker_flags,   [ "-lfoo", "-lbar" ],
      '$build->extra_linker_flags merged' );
}

done_testing;