File: file_path.t

package info (click to toggle)
libpkgconfig-perl 0.26026-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,912 kB
  • sloc: ansic: 6,120; perl: 1,922; makefile: 4; sh: 3
file content (47 lines) | stat: -rw-r--r-- 1,088 bytes parent folder | download | duplicates (3)
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
use strict;
use warnings;
use PkgConfig;
use File::Temp qw( tempdir );
use Test::More tests => 2;
use File::Spec;

my $dir = tempdir( CLEANUP => 1);

note "dir = $dir";

my $fn = File::Spec->catfile($dir, "libfoo.pc");
open my $fh, '>', $fn;
while(<DATA>) { print $fh $_ }
close $fh;

subtest 'no such file' => sub {

    plan tests => 2;
    my $pkg = PkgConfig->find( 'rubbish', file_path => File::Spec->catfile($dir, "rubbifsh.pc") );
    isa_ok $pkg, 'PkgConfig';
    like $pkg->errmsg, qr{^No such file}, "error";

};

subtest 'real file' => sub {

    plan tests => 3;
    my $pkg = PkgConfig->find( 'rubbish', file_path => File::Spec->catfile($dir, "libfoo.pc") );
    isa_ok $pkg, 'PkgConfig';

    is join(' ', $pkg->get_cflags),  '-I/opt/stuff/include -DFOO=1', 'cflags';
    is join(' ', $pkg->get_ldflags), '-L/opt/stuff/lib -lfoo',       'ldflags';
};

__DATA__
prefix=/opt/stuff
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include

Name: libfoo
Description: Foo
Version: 1.2.3
URL: http://foo.bar/
Libs: -L${libdir} -lfoo
Cflags: -I${includedir} -DFOO=1