From: Vincent Pit Date: Mon, 30 Mar 2015 20:01:51 +0000 (-0300) Subject: Set PERL_DESTRUCT_LEVEL through the environment variable on debugging perls X-Git-Tag: v0.57~17 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=abc9974f53e87f80925e626771ff1546dba71f93;p=perl%2Fmodules%2FVariable-Magic.git Set PERL_DESTRUCT_LEVEL through the environment variable on debugging perls --- diff --git a/t/lib/Variable/Magic/TestGlobalDestruction.pm b/t/lib/Variable/Magic/TestGlobalDestruction.pm index b616a8e..34c4b59 100644 --- a/t/lib/Variable/Magic/TestGlobalDestruction.pm +++ b/t/lib/Variable/Magic/TestGlobalDestruction.pm @@ -75,18 +75,22 @@ sub import { my $env_level = $ENV{PERL_DESTRUCT_LEVEL}; if (defined $env_level) { - $env_level = do { - no warnings 'numeric'; - int $env_level; - }; + no warnings 'numeric'; + $env_level = int $env_level; + } - my $is_debugging = is_debugging_perl(); - if ($is_debugging) { - _diag("Global destruction level $env_level set by PERL_DESTRUCT_LEVEL (debugging perl)"); + my $is_debugging = is_debugging_perl(); + if ($is_debugging) { + if (defined $env_level) { + _diag("Global destruction level $env_level set by PERL_DESTRUCT_LEVEL (environment)"); return ($env_level >= $level) ? 1 : 0; } else { - _diag("PERL_DESTRUCT_LEVEL is set to $env_level, but this perl doesn't seem to have debugging enabled, ignoring"); + $ENV{PERL_DESTRUCT_LEVEL} = $level; + _diag("Global destruction level $level set by PERL_DESTRUCT_LEVEL (forced)"); + return 1; } + } elsif (defined $env_level) { + _diag("PERL_DESTRUCT_LEVEL is set to $env_level, but this perl doesn't seem to have debugging enabled, ignoring"); } my $has_perl_destruct_level = do {