Skip to content

Commit c515847

Browse files
committed
Split test target to better handle -Uusedl
1 parent 04428dc commit c515847

File tree

1 file changed

+42
-53
lines changed

1 file changed

+42
-53
lines changed

lib/ExtUtils/MM_Unix.pm

Lines changed: 42 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3615,8 +3615,6 @@ Defines the test targets.
36153615
=cut
36163616

36173617
sub test {
3618-
# --- Test and Installation Sections ---
3619-
36203618
my($self, %attribs) = @_;
36213619
my $tests = $attribs{TESTS} || '';
36223620
if (!$tests && -d 't' && defined $attribs{RECURSIVE_TEST_FILES}) {
@@ -3628,8 +3626,9 @@ sub test {
36283626
# have to do this because nmake is broken
36293627
$tests =~ s!/!\\!g if $self->is_make_type('nmake');
36303628
# note: 'test.pl' name is also hardcoded in init_dirscan()
3631-
my(@m);
3632-
push(@m,"
3629+
my @m;
3630+
my $default_testtype = $Config{usedl} ? 'dynamic' : 'static';
3631+
push @m, <<EOF;
36333632
TEST_VERBOSE=0
36343633
TEST_TYPE=test_\$(LINKTYPE)
36353634
TEST_FILE = test.pl
@@ -3639,61 +3638,51 @@ TESTDB_SW = -d
36393638
testdb :: testdb_\$(LINKTYPE)
36403639
\$(NOECHO) \$(NOOP)
36413640
3642-
test :: \$(TEST_TYPE) subdirs-test
3643-
\$(NOECHO) \$(NOOP)
3644-
3645-
subdirs-test ::
3646-
\$(NOECHO) \$(NOOP)
3647-
3648-
# defined here as well as top_targets in case someone overrides that
3649-
pure_nolink ::
3641+
test :: \$(TEST_TYPE)
36503642
\$(NOECHO) \$(NOOP)
36513643
36523644
# Occasionally we may face this degenerate target:
3653-
test_ : test_dynamic
3645+
test_ : test_$default_testtype
36543646
\$(NOECHO) \$(NOOP)
36553647
3656-
");
3657-
3658-
foreach my $dir (@{ $self->{DIR} }) {
3659-
my $test = $self->cd($dir, '$(MAKE) test $(PASTHRU)');
3648+
EOF
36603649

3661-
push @m, <<END
3662-
subdirs-test ::
3663-
\$(NOECHO) $test
3650+
for my $linktype (qw(dynamic static)) {
3651+
push @m, "subdirs-test_$linktype :: $linktype\n";
3652+
foreach my $dir (@{ $self->{DIR} }) {
3653+
my $test = $self->cd($dir, "\$(MAKE) test_$linktype \$(PASTHRU)");
3654+
push @m, "\t\$(NOECHO) $test\n";
3655+
}
3656+
push @m, "\n";
3657+
if ($tests or -f "test.pl") {
3658+
for my $testspec ([ '', '' ], [ 'db', ' $(TESTDB_SW)' ]) {
3659+
my ($db, $switch) = @$testspec;
3660+
my ($command, $deps);
3661+
$deps = "$linktype subdirs-test_$linktype";
3662+
if ($linktype eq 'static' and $self->needs_linking) {
3663+
my $target = File::Spec->rel2abs('$(MAP_TARGET)');
3664+
$command = qq{"$target" \$(MAP_PERLINC)};
3665+
$deps .= ' $(MAP_TARGET)';
3666+
} else {
3667+
$command = '$(FULLPERLRUN)' . $switch;
3668+
}
3669+
push @m, "test${db}_$linktype :: $deps\n";
3670+
push @m, $self->test_via_harness($command, '$(TEST_FILES)')
3671+
if $tests;
3672+
push @m, $self->test_via_script($command, '$(TEST_FILE)')
3673+
if -f "test.pl";
3674+
push @m, "\n";
3675+
}
3676+
} else {
3677+
push @m, _sprintf562 <<'EOF', $linktype;
3678+
testdb_%1$s test_%1$s :: %1$s subdirs-test_%1$s
3679+
$(NOECHO) $(ECHO) 'No tests defined for $(NAME) extension.'
36643680
3665-
END
3681+
EOF
3682+
}
36663683
}
36673684

3668-
push(@m, "test_dynamic :: dynamic\n");
3669-
push(@m, $self->test_via_harness('$(FULLPERLRUN)', '$(TEST_FILES)'))
3670-
if $tests;
3671-
push(@m, $self->test_via_script('$(FULLPERLRUN)', '$(TEST_FILE)'))
3672-
if -f "test.pl";
3673-
push(@m, "\t\$(NOECHO) \$(ECHO) 'No tests defined for \$(NAME) extension.'\n")
3674-
unless $tests or -f "test.pl" or @{$self->{DIR}};
3675-
push(@m, "\n");
3676-
3677-
push(@m, "testdb_dynamic :: dynamic\n");
3678-
push(@m, $self->test_via_script('$(FULLPERLRUN) $(TESTDB_SW)',
3679-
'$(TEST_FILE)'));
3680-
push(@m, "\n");
3681-
3682-
if ($self->needs_linking and ($tests or -f "test.pl")) {
3683-
push(@m, "test_static :: static \$(MAP_TARGET)\n");
3684-
my $target = File::Spec->rel2abs('$(MAP_TARGET)');
3685-
my $command = qq{"$target" \$(MAP_PERLINC)};
3686-
push(@m, $self->test_via_harness($command, '$(TEST_FILES)')) if $tests;
3687-
push(@m, $self->test_via_script($command, '$(TEST_FILE)')) if -f "test.pl";
3688-
push(@m, "\n");
3689-
push(@m, "testdb_static :: static \$(MAP_TARGET)\n");
3690-
push(@m, $self->test_via_script("$command \$(TESTDB_SW)", '$(TEST_FILE)'));
3691-
push(@m, "\n");
3692-
} else {
3693-
push @m, "test_static :: test_dynamic\n";
3694-
push @m, "testdb_static :: testdb_dynamic\n";
3695-
}
3696-
join("", @m);
3685+
join "", @m;
36973686
}
36983687

36993688
=item test_via_harness (override)
@@ -3828,7 +3817,7 @@ sub top_targets {
38283817

38293818
push @m, $self->all_target, "\n" unless $self->{SKIPHASH}{'all'};
38303819

3831-
push @m, '
3820+
push @m, sprintf <<'EOF', $Config{usedl} ? 'dynamic' : 'static';
38323821
pure_all :: linkext
38333822
$(NOECHO) $(NOOP)
38343823
@@ -3840,7 +3829,7 @@ subdirs :: subdirs_$(LINKTYPE)
38403829
$(NOECHO) $(NOOP)
38413830
38423831
# in case LINKTYPE not set
3843-
subdirs_ :: subdirs_dynamic
3832+
subdirs_ :: subdirs_%s
38443833
$(NOECHO) $(NOOP)
38453834
38463835
subdirs_pure_nolink ::
@@ -3861,7 +3850,7 @@ static :: pure_nolink
38613850
38623851
dynamic :: pure_nolink
38633852
$(NOECHO) $(NOOP)
3864-
';
3853+
EOF
38653854

38663855
push @m, '
38673856
$(O_FILES) : $(H_FILES)

0 commit comments

Comments
 (0)