Skip to content

Commit 9815ff9

Browse files
committed
ParseXS: add tests for standard_typemap_locations
Add some more tests to ExtUtils-ParseXS/t/101-standard_typemap_locations. In particular, this time with a faked-up @inc. This is mainly so that the next few commits will only change the things we expect when updating standard_typemap_locations(). Note that this new test directly tests for expected strings such as '../../typemap', rather than using File::Spec->updir() etc. This is to avoid the test code being essentially a duplicate of the sub code. It skips this test on platforms which don't seem to use '..' etc.
1 parent bb468b7 commit 9815ff9

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

dist/ExtUtils-ParseXS/t/101-standard_typemap_locations.t

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/perl
22
use strict;
33
use warnings;
4-
use Test::More tests => 3;
4+
use Test::More tests => 5;
55
use ExtUtils::ParseXS::Utilities qw(
66
standard_typemap_locations
77
);
@@ -35,3 +35,40 @@ use ExtUtils::ParseXS::Utilities qw(
3535
}
3636
}
3737

38+
{
39+
my @fake_INC = qw(a/b/c d/e/f /g/h/i);
40+
my @expected =
41+
(
42+
qw(
43+
../../../../lib/ExtUtils/typemap
44+
../../../../typemap
45+
../../../lib/ExtUtils/typemap
46+
../../../typemap
47+
../../lib/ExtUtils/typemap
48+
../../typemap
49+
../lib/ExtUtils/typemap
50+
../typemap
51+
typemap
52+
)
53+
);
54+
55+
my @stl = standard_typemap_locations( \@fake_INC );
56+
57+
is(scalar @stl, scalar @expected,
58+
"with fake INC: corrrect number of entries in typemap locations list" );
59+
60+
SKIP: {
61+
# Only do a full string comparison on platforms which handle
62+
# "standard" pathname formats and '..' updirs. We *always* test
63+
# on linux, and otherwise test unless the second from last doesn't
64+
# look standard. Always testing on Linux means there is at least
65+
# one platform that won't falsely skip the test if garbage is
66+
# returned.
67+
skip "platform doesn't use ../..", 1
68+
if $^O ne 'linux'
69+
and $stl[-2] ne '../typemap';
70+
71+
is_deeply(\@stl, \@expected, "with fake INC: list of paths match");
72+
}
73+
}
74+

0 commit comments

Comments
 (0)