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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
#
# $Id$
#
use strict;
use warnings;
use Test::More tests => 24;
use ExtUtils::PkgConfig;
require 't/swallow_stderr.inc';
$ENV{PKG_CONFIG_PATH} = './t/';
sub contains {
my ($string, $sub_string) = @_;
return -1 != index ($string, $sub_string);
}
my $macros;
$macros = ExtUtils::PkgConfig->create_version_macros (qw/test_glib-2.0/, 'GLIB');
ok (contains ($macros, 'GLIB_MAJOR_VERSION (2)'));
ok (contains ($macros, 'GLIB_MINOR_VERSION (2)'));
ok (contains ($macros, 'GLIB_MICRO_VERSION (3)'));
ok (contains ($macros, 'GLIB_CHECK_VERSION'));
# Check that '2.0b2.4' is turned into 2.0.4
$macros = ExtUtils::PkgConfig->create_version_macros (qw/test_non_numeric/, 'TEST');
ok (contains ($macros, 'TEST_MAJOR_VERSION (2)'));
ok (contains ($macros, 'TEST_MINOR_VERSION (0)'));
ok (contains ($macros, 'TEST_MICRO_VERSION (4)'));
ok (contains ($macros, 'TEST_CHECK_VERSION'));
# Check that '2' is turned into 2.0.0
$macros = ExtUtils::PkgConfig->create_version_macros (qw/test_short/, 'TEST');
ok (contains ($macros, 'TEST_MAJOR_VERSION (2)'));
ok (contains ($macros, 'TEST_MINOR_VERSION (0)'));
ok (contains ($macros, 'TEST_MICRO_VERSION (0)'));
ok (contains ($macros, 'TEST_CHECK_VERSION'));
swallow_stderr (sub {
eval {
ExtUtils::PkgConfig->create_version_macros (qw/__bad__/, 'BAD');
};
ok ($@);
});
my $header = 'eupc_test_tmp.h';
ExtUtils::PkgConfig->write_version_macros (
$header,
'test_glib-2.0' => 'GLIB',
'test_non_numeric' => 'TEST');
ok (-f $header);
ok (open my $fh, '<', $header);
$/ = undef; $macros = <$fh>;
ok (contains ($macros, 'GLIB_MAJOR_VERSION'));
ok (contains ($macros, 'GLIB_MINOR_VERSION'));
ok (contains ($macros, 'GLIB_MICRO_VERSION'));
ok (contains ($macros, 'GLIB_CHECK_VERSION'));
ok (contains ($macros, 'TEST_MAJOR_VERSION'));
ok (contains ($macros, 'TEST_MINOR_VERSION'));
ok (contains ($macros, 'TEST_MICRO_VERSION'));
ok (contains ($macros, 'TEST_CHECK_VERSION'));
close $fh;
unlink $header;
swallow_stderr (sub {
eval {
ExtUtils::PkgConfig->write_version_macros (
$header,
'__bad__' => 'BAD');
};
ok ($@);
});
if (-f $header) {
unlink $header;
}
|