Skip to content

Commit 1653a15

Browse files
committed
calculate CAN_SIGSYS when called rather than as a constant
CAN_SIGSYS is not used by Test2 anymore since the removal of the shm code in 4c1bdd2. It is however still used by Test2::Harness. %Config has magic behavior where some values exist in Config.pm, and others need to load Config_heavy.pl. Checking the sig_name value will always force Config_heavy.pl to be loaded. Since CAN_SIGSYS is mostly not used, having it always force loading the heavy config provides a minor slowdown of loading Test::More. We can provide the function as a runtime check rather than a constant to avoid this.
1 parent 8e80a95 commit 1653a15

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

lib/Test2/API/Instance.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ our @CARP_NOT = qw/Test2::API Test2::API::Instance Test2::IPC::Driver Test2::For
88
use Carp qw/confess carp/;
99
use Scalar::Util qw/reftype/;
1010

11-
use Test2::Util qw/get_tid USE_THREADS CAN_FORK pkg_to_file try CAN_SIGSYS/;
11+
use Test2::Util qw/get_tid USE_THREADS CAN_FORK pkg_to_file try/;
1212

1313
use Test2::EventFacet::Trace();
1414
use Test2::API::Stack();

lib/Test2/Util.pm

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,12 @@ sub _check_for_sig_sys {
166166
return $sig_list =~ m/\bSYS\b/;
167167
}
168168

169-
BEGIN {
170-
if (_check_for_sig_sys($Config{sig_name})) {
171-
*CAN_SIGSYS = sub() { 1 };
172-
}
173-
else {
174-
*CAN_SIGSYS = sub() { 0 };
169+
my $CAN_SIGSYS;
170+
sub CAN_SIGSYS () {
171+
if (!defined $CAN_SIGSYS) {
172+
$CAN_SIGSYS = _check_for_sig_sys($Config{sig_name});
175173
}
174+
$CAN_SIGSYS;
176175
}
177176

178177
my %PERLIO_SKIP = (

0 commit comments

Comments
 (0)