Skip to content
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

fix: test 'spell::hunspell::tests::correctly_expands_test_files' failed #157

Merged
merged 1 commit into from
Sep 10, 2024
Merged

Conversation

Cryolitia
Copy link
Contributor

@Cryolitia Cryolitia commented Sep 10, 2024

The test spell::hunspell::tests::correctly_expands_test_files iterates over a HashMap and collects the results, but the results assume that the collected array is in a specific order. Rust does not guarantee the order in which HashMap is iterated, and the order depends on the specific implementation of Rust's hash function on the platform.

It is on the Rust Doc that said:

An iterator visiting all key-value pairs in arbitrary order. The iterator element type is (&'a K, &'a V).

Due to differences in endianness and type sizes, data fed by Hash to a Hasher should not be considered portable across platforms. Additionally the data passed by most standard library types should not be considered stable between compiler versions.

Specifically, I found that so far, the results of running this test on different platforms are:

  • x86_64-linux
  • aarch64-linux
  • riscv64-linux (SG2042)
  • riscv64-linux (qemu-user)
  • loongarch64-linux (3A5000)

On all of SG2042, qemu-user-riscv64, 3A5000, this test will fail with the same output:

failures:

---- spell::hunspell::tests::correctly_expands_test_files stdout ----
thread 'spell::hunspell::tests::correctly_expands_test_files' panicked at harper-core/src/spell/hunspell/mod.rs:96:9:
assertion `left == right` failed
  left: ["try", "tried", "rework", "work", "worked", "hello", "reworked"]
 right: ["hello", "tried", "reworked", "rework", "worked", "work", "try"]
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    spell::hunspell::tests::correctly_expands_test_files

This patch has been tested on:

  • x86_64-linux
  • aarch64-linux
  • riscv64-linux (SG2042)
  • riscv64-linux (qemu-user)
  • loongarch64-linux

Reported-by: https://archriscv.felixc.at/.status/log.htm?url=logs/harper/harper-0.10.0-1.log

@elijah-potter
Copy link
Collaborator

This all checks out. Would you mind running just format real quick and committing the resulting changes? Once that's done I'll merge it. Thanks for fixing that!

No assumptions should be made about the order in which a HashMap is iterated
@Cryolitia
Copy link
Contributor Author

Code format done

Plus, I managed to get a loongarch64-linux and test it on it, results updated above.

Thanks for your reply ^_^

@elijah-potter elijah-potter merged commit 1336712 into Automattic:master Sep 10, 2024
2 checks passed
Cryolitia added a commit to Cryolitia-Forks/archriscv-packages that referenced this pull request Sep 11, 2024
Cryolitia added a commit to Cryolitia-Forks/archriscv-packages that referenced this pull request Sep 11, 2024
felixonmars pushed a commit to felixonmars/archriscv-packages that referenced this pull request Sep 11, 2024
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