Skip to content

Commit 90886bd

Browse files
committed
XSConfig compatibility
With XSConfig with p5p perl, or cperl, Test::Harness fails in t/nofork-mux.t because of reliance on internal implementation of Config.pm. Without using any external libraries or modules, fake not having fork by putting a shim between the XS FETCH sub/method and the Config class that traps and changes 'd_fork' key. Sample of error below that is fixed with this patch. C:\cpan\testharness>prove -v t/nofork-mux.t t/nofork-mux.t .. Not a HASH reference at t/lib/NoFork.pm line 7. Compilation failed in require at t/nofork-mux.t line 10. BEGIN failed--compilation aborted at t/nofork-mux.t line 10. Dubious, test returned 255 (wstat 65280, 0xff00) No subtests run Test Summary Report ------------------- t/nofork-mux.t (Wstat: 65280 Tests: 0 Failed: 0) Non-zero exit status: 255 Parse errors: No plan found in TAP output Files=1, Tests=0, 0 wallclock secs ( 0.11 usr + 0.00 sys = 0.11 CPU) Result: FAIL Original author of this code is Reini Urban, in cperl commit 42cac300080de7d3a9df8eed040750ec9583de20 "Test-Harness: fix 2 tests" on "Date: 9/28/2015 10:59:36 AM". The code was submitted upstream in Apr 2017 in Perl-Toolchain-Gang#63 but that PR stalled. I've extracted the minimum code needed to get T::H to pass with XSConfig with p5p perl and placed it in this patch so that the code can be published sooner.
1 parent 0c59c50 commit 90886bd

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

t/lib/NoFork.pm

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,21 @@ BEGIN {
44
*CORE::GLOBAL::fork = sub { die "you should not fork" };
55
}
66
use Config;
7-
tied(%Config)->{d_fork} = 0; # blatant lie
7+
if ($Config::Config{d_fork}) {
8+
if (exists &Config::KEYS) { # compiled Config
9+
*Config_FETCHorig = \&Config::FETCH;
10+
no warnings 'redefine';
11+
*Config::FETCH = sub {
12+
if ($_[0] and $_[1] eq 'd_fork') {
13+
return 0;
14+
} else {
15+
return Config_FETCHorig(@_);
16+
}
17+
}
18+
} else {
19+
tied(%Config)->{d_fork} = 0; # uncompiled Config
20+
}
21+
}
822

923
=begin TEST
1024

0 commit comments

Comments
 (0)