Skip to content

test with predictable hashes #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

test with predictable hashes #5

wants to merge 2 commits into from

Conversation

szabgab
Copy link
Contributor

@szabgab szabgab commented Oct 9, 2013

No description provided.

@mschilli
Copy link
Owner

Wouldn't this skip all tests on older perls that don't have this hash jumble feature at all and therefore don't cause the problem?

@szabgab
Copy link
Contributor Author

szabgab commented Oct 10, 2013

Oh right, so you probably also need to condition it on >= 5.18

@szabgab szabgab closed this Oct 10, 2013
@szabgab szabgab reopened this Oct 10, 2013
@szabgab
Copy link
Contributor Author

szabgab commented Oct 10, 2013

closed by mistake (screen is to small and I only saw the close button :)

@mschilli
Copy link
Owner

Can you explain what the code does? On my Macbook perl neither of these variables are set. Are they set on yours?

@szabgab
Copy link
Contributor Author

szabgab commented Oct 15, 2013

Hmm, what I did there was I think a bit stupid. Only the problematic cases should be wrapped in the skip block and that should also be conditioned on the version of Perl. Then you'd run the test as

PERL_PERTURB_KEYS=0 PERL_HASH_SEED=1 prove -lv t/001Basic.t

or as

PERL_PERTURB_KEYS=0 PERL_HASH_SEED=1 make test

@mschilli
Copy link
Owner

Does adding

$ENV{ PERL_PERTURB_KEYS } = "DETERMINISTIC";
$ENV{ PERL_HASH_SEED } = 1;

to t/001Basic.t also work with your perl version?

@szabgab
Copy link
Contributor Author

szabgab commented Oct 16, 2013

As far as I understand (and checked) one needs to set those environment variable before perl starts to run, so we cannot do it in the test script. It has to be done in the environment. See the examples in the code.
I think the DETERMINISTIC (2) will not work properly as that would mean the results are different on older perls and newer perls. from perldoc perlrun:

 PERL_PERTURB_KEYS
               (Since Perl 5.18.0)  Set to "0" or "NO" then traversing keys will be repeatable
               from run to run for the same PERL_HASH_SEED.  Insertion into a hash will not
               change the order, except to provide for more space in the hash. When combined
               with setting PERL_HASH_SEED this mode is as close to pre 5.18 behavior as you can
               get.

but I have not updated the comment yet.

I think the most recent change I pushed will work. I tested it on 5.18.0 and now it works both with and without the environment variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants