Skip to content

Commit c644449

Browse files
committed
Isolate DETERMINISTIC and mark it as TODO
Relates: Perl#250 PL_HASH_RAND_BITS_ENABLED=2 does not seem to be a reproducible state when setting PERL_PERTURB_KEYS.
1 parent c5b357e commit c644449

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

t/run/xrunenv.t

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ BEGIN {
1212
skip_all_without_config('d_fork');
1313
}
1414

15-
#plan tests => 112;
1615
plan tests => 6;
1716

1817
my $STDOUT = tempfile();
@@ -62,6 +61,7 @@ sub runperl_and_capture {
6261
}
6362
}
6463

64+
our $TODO;
6565
SKIP:
6666
{
6767
#skip "NO_PERL_HASH_ENV or NO_PERL_HASH_SEED_DEBUG set", 16
@@ -71,19 +71,23 @@ SKIP:
7171

7272
# Test that PERL_PERTURB_KEYS works as expected. We check that we get the same
7373
# results if we use PERL_PERTURB_KEYS = 0 or 2 and we reuse the seed from previous run.
74-
my @print_keys = ( '-e', '@_{"A".."Z"}=(); print keys %_');
75-
for my $mode ( 0,1, 2 ) { # disabled and deterministic respectively
74+
my @print_keys = ( '-e', 'my %h; @h{"A".."Z"}=(); print keys %h');
75+
for my $mode ( qw{NO RANDOM DETERMINISTIC} ) { # 0, 1 and 2 respectively
7676
my %base_opts;
7777
%base_opts = ( PERL_PERTURB_KEYS => $mode, PERL_HASH_SEED_DEBUG => 1 ),
7878
my ($out, $err) = runperl_and_capture( { %base_opts }, [ @print_keys ]);
7979
if ($err=~/HASH_SEED = (0x[a-f0-9]+)/) {
8080
my $seed = $1;
8181
my($out2, $err2) = runperl_and_capture( { %base_opts, PERL_HASH_SEED => $seed }, [ @print_keys ]);
82-
if ( $mode == 1 ) {
82+
if ( $mode eq 'RANDOM' ) {
8383
isnt ($out,$out2,"PERL_PERTURB_KEYS = $mode results in different key order with the same key");
84-
} else {
84+
} elsif ( $mode eq 'NO' ) {
85+
is ($out,$out2,"PERL_PERTURB_KEYS = $mode allows one to recreate a random hash");
86+
} elsif ( $mode eq 'DETERMINISTIC' ) {
87+
local $TODO = q[need to check DETERMINISTIC mode];
8588
is ($out,$out2,"PERL_PERTURB_KEYS = $mode allows one to recreate a random hash");
8689
}
90+
8791
is ($err,$err2,"Got the same debug output when we set PERL_HASH_SEED and PERL_PERTURB_KEYS");
8892
}
8993
}

0 commit comments

Comments
 (0)