-
Notifications
You must be signed in to change notification settings - Fork 51
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
Unstable parser tests #29
Comments
Output from a failed test:
|
Oh, and:
|
I admit I sit on Perl 5.16, and yes, tests run fine for me (no differences between runs). Try running I'll also upgrade to the newer version of Perl and see if I can reproduce this. |
I ran The differences appear to mostly be in the ordering of items in the DB, however some of the changes appear to be ids (or other checksum values) which I would expect to be stable (but I have not looked at the inputs to generate the checksum). After running this the tests continue to fail when run with |
Oh, and I just ran |
It just occurred to me that it’s probably pretty easy for me to spin up a Docker container with a pre 5.18 version of Perl and see if I can get stability on the original tests and the ones I hope to add. |
Ok, I just confirmed that running the tests in a container with 5.16.3 causes the tests to be stable. I will submit my PR with data it generated (once I fix the bug I discovered now that I can trust the tests I did not write) But this further implicates the changes in 5.18, and the most likely culprit is the hashing algorithm overhaul. |
Just a quick update: this is reproducible in Perl 5.22. This is a quick test: Go to $ serge test-parser parse_json strings.json Every time you run it, the dumped data structure (the order of the strings if which they are reported by the parser callback) will be different. |
I looked at the JSON/YAML parser documentation and the only easy way to solve this is to sort object keys at each level; this is guaranteed to stabilize the output. Unfortunately, there's no way to tell the parsers to use e.g. A more involving way to solve this would be to find (or write) streaming callback-based parsers that will report the structure as it is parsed, allowing us ultimately to preserve the original order. Given the fact that both JSON and YAML specs state that the order of the keys in the object/dictionary is not important and is not guaranteed, I think it's safe to go with the first (easy) option. |
In my environment, the parser tests (specifically for parse_yaml & parse_json) are unstable. They fail most of the time, but on occasion will pass.
I thought this might be due to the deliberate randomization of hash keys in 5.18, and it seems (anecdotally) that setting
PERL_PERTURB_KEYS=0
does appear to help some of the tests, it does not guarantee a successful run.Am I right in assuming these tests are consistent for you, and there is something else in my environment causing this issue?
The text was updated successfully, but these errors were encountered: