Skip to content

Commit 0134d4a

Browse files
committed
Test, fix linkext=>{LINKTYPE=>""} with/without subdirs present
1 parent 80d00e5 commit 0134d4a

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

lib/ExtUtils/MM_Unix.pm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2397,7 +2397,8 @@ sub linkext {
23972397
# we can bring in subdirs_(perl-linktype) for back-compat
23982398
my $linktype = $attribs{LINKTYPE};
23992399
$linktype = $self->{LINKTYPE} unless defined $linktype;
2400-
if (defined $linktype and $linktype eq '' and @{ $self->{DIR} || [] }) {
2400+
if (defined $linktype and $linktype eq '') {
2401+
# bring in subdirs even if none exist as brings in pure_nolink
24012402
warn "Warning: LINKTYPE set to '', no longer necessary\n";
24022403
$extra = 'subdirs_' . ($Config{usedl} ? 'dynamic' : 'static');
24032404
}

t/basic.t

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use ExtUtils::MM;
2424
use Test::More
2525
!MM->can_run(make()) && $ENV{PERL_CORE} && $Config{'usecrosscompile'}
2626
? (skip_all => "cross-compiling and make not available")
27-
: (tests => 169);
27+
: (tests => 179);
2828
use File::Find;
2929
use File::Spec;
3030
use File::Path;
@@ -162,7 +162,7 @@ is( $?, 0, 'install' ) || diag $install_out;
162162
like( $install_out, qr/^Installing /m );
163163

164164
sub check_dummy_inst {
165-
my $loc = shift;
165+
my ($loc, $skipsubdir) = @_;
166166
my %files = ();
167167
find( sub {
168168
# do it case-insensitive for non-case preserving OSs
@@ -172,7 +172,7 @@ sub check_dummy_inst {
172172
$files{$file} = $File::Find::name;
173173
}, $loc );
174174
ok( $files{'dummy.pm'}, ' Dummy.pm installed' );
175-
ok( $files{'liar.pm'}, ' Liar.pm installed' );
175+
ok( $files{'liar.pm'}, ' Liar.pm installed' ) unless $skipsubdir;
176176
ok( $files{'program'}, ' program installed' );
177177
ok( $files{'.packlist'}, ' packlist created' );
178178
ok( $files{'perllocal.pod'},' perllocal.pod created' );
@@ -433,6 +433,27 @@ is( $?, 0, 'realclean' ) || diag($realclean_out);
433433
open(STDERR, ">&SAVERR") or die $!;
434434
close SAVERR;
435435

436+
# test linkext=>{LINKTYPE=>''} still installs a pure-perl installation
437+
# warning, edits the Makefile.PL so either rewrite after this or do this last
438+
my $file = 'Makefile.PL';
439+
my $text = slurp $file;
440+
ok(($text =~ s#\);# linkext=>{LINKTYPE=>''},\n$&#), 'successful M.PL edit');
441+
open $fh, '>', $file or die "$file: $!";
442+
print $fh $text;
443+
close $fh;
444+
# now do with "Liar" subdir still there
445+
rmtree $DUMMYINST; # so no false positive from before
446+
@mpl_out = run(qq{$perl Makefile.PL "PREFIX=$DUMMYINST"});
447+
$install_out = run("$make install");
448+
check_dummy_inst($DUMMYINST);
449+
# now clean, delete "Liar" subdir, do again
450+
$realclean_out = run("$make realclean");
451+
rmtree 'Liar';
452+
rmtree $DUMMYINST; # so no false positive from before
453+
@mpl_out = run(qq{$perl Makefile.PL "PREFIX=$DUMMYINST"});
454+
$install_out = run("$make install");
455+
check_dummy_inst($DUMMYINST, 1);
456+
436457
sub _normalize {
437458
my $hash = shift;
438459

0 commit comments

Comments
 (0)