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 flaky tests #185

Merged
merged 1 commit into from
Oct 26, 2023
Merged

Fix flaky tests #185

merged 1 commit into from
Oct 26, 2023

Conversation

dserfe
Copy link

@dserfe dserfe commented Oct 25, 2023

This PR is to fix flaky tests.

Problem

If test jnr.posix.EnvTest#testSetenvOverwrite runs before any of the following 6 tests, it will pollute the shared status, thus these 6 tests will fail:

jnr.posix.GroupTest#getgroups,
jnr.posix.NlLanginfoTest#testNlLanginfo,
jnr.posix.SpawnTest#closeInput,
jnr.posix.SpawnTest#inputPipe,
jnr.posix.SpawnTest#outputPipe,
jnr.posix.SpawnTest#validPid

For example, we get the following test failures:

[ERROR] Failures: 
[ERROR]   SpawnTest.closeInput:182
[ERROR]   SpawnTest.inputPipe:107
[ERROR]   SpawnTest.outputPipe:73
[ERROR]   SpawnTest.validPid:44
[ERROR] Errors: 
[ERROR]   GroupTest.getgroups:92->exec:122 » IO Cannot run program "id": error=2, No such file or directory
[ERROR]   NlLanginfoTest.testNlLanginfo:28 » IO Cannot run program "locale": error=2, No such file or directory

Root cause and fix:

Line 38 of jnr.posix.EnvTest#testSetenvOverwrite changes the property related to "PATH" to "new value", but at the end of the test, it didn't reset it back. Therefore, the fix is to change it back at the end of test, which can clean the pollution to other tests.

@enebo
Copy link
Member

enebo commented Oct 26, 2023

@dserfe yeah good catch. Thanks for your contribution!

@enebo enebo merged commit 3b3e32f into jnr:master Oct 26, 2023
3 checks passed
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