-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
headers.t
48 lines (41 loc) · 1.34 KB
/
headers.t
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
use strict;
# compatible use warnings
BEGIN{ if (not $] < 5.006) { require warnings; warnings->import } }
use lib 't/lib';
use Capture::Tiny qw(capture);
use Config;
use File::Spec;
use Test::More;
eval "use Devel::CheckLib";
if($@ =~ /Couldn't find your C compiler/) {
plan skip_all => "Couldn't find your C compiler";
}
my $debug = $ENV{DEVEL_CHECKLIB_DEBUG} || 0;
# cases are strings to interpolate into the assert_lib call
my %failcases = (
qq{incpath => '.', header => 'headerfile.h'} => "Can't link/include",
qq{INC => '-t/inc', header => 'headerfile.h'} => "INC argument badly-formed"
);
my @passcases = (
qq{incpath => '.', header => 't/inc/headerfile.h'},
qq{incpath => [qw(t/inc)], header => 'headerfile.h'},
qq{INC => '-I. -It/inc', header => 'headerfile.h'}
);
plan tests => scalar(keys %failcases) + scalar(@passcases);
for my $c (keys %failcases) {
my $error;
my ($stdout, $stderr) = capture {
eval "assert_lib(debug => $debug, $c)";
$error = $@;
};
ok($error =~ /^$failcases{$c}/, "$c") ||
diag("$@\n\tSTDOUT: $stdout\n\tSTDERR: $stderr\n");
}
for my $c ( @passcases ) {
my $error;
my ($stdout, $stderr) = capture {
eval "assert_lib(debug => $debug, $c)";
$error = $@;
};
is($error, q{}, "$c") || diag("\tSTDOUT: $stdout\n\tSTDERR: $stderr\n");
}