Skip to content

Fix occasional test failure due to env::set_var with multiple test threads #421

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

Merged
merged 3 commits into from
Jul 12, 2019

Conversation

spl
Copy link
Contributor

@spl spl commented Jul 8, 2019

Tests that modify environment variables (e.g. CFLAGS and CXXFLAGS) can cause tests to fail when run in parallel because they change a shared context.

This change moves the problematic tests into separate modules. Since each tests/*.rs is compiled as a separate crate, these tests are not run in parallel with other tests.

@alexcrichton
Copy link
Member

Thanks! Could this also remove the --test-threads 1 argument we pass on CI?

@spl
Copy link
Contributor Author

spl commented Jul 9, 2019

Could this also remove the --test-threads 1 argument we pass on CI?

This and #419 are the only problems I've encountered with parallel test threads. Unfortunately, the work I've been doing on cc-rs exacerbated these issues, which is why I've been chasing them down.

@alexcrichton
Copy link
Member

It seems the intention of this PR is to basically enable cargo test though, right? If that's the case we should be able to run that on CI to verify it?

@spl
Copy link
Contributor Author

spl commented Jul 10, 2019

I guess you're suggesting that I remove --test-threads 1 in CI. I don't think this PR is enough to allow that, since #419 is unresolved, but at least you can see the result now (1f81b89, build results).

Tests that modify environment variables (e.g. CFLAGS and CXXFLAGS) can
cause tests to fail when run in parallel because they change a shared
context.

This change moves the problematic tests into separate modules. Since
each `tests/*.rs` is compiled as a separate crate, these tests are not
run in parallel with other tests.
@spl spl force-pushed the serialize-env-tests branch from 1f81b89 to aa968a0 Compare July 11, 2019 08:10
@spl
Copy link
Contributor Author

spl commented Jul 11, 2019

It seems like my hack (aa968a0) is not enough to “fix” #419 on Azure (build results).

@alexcrichton
Copy link
Member

Ah ok, if that's the case mind if we hold off on this? Right now the test suite just needs to be run with one thread, but if there's more lurking then I'd prefer if it were all fixed instead of only having half of it fixed

@spl
Copy link
Contributor Author

spl commented Jul 11, 2019

Alternatively, with d098048 implemented, it seems like you only need --test-threads 1 on macOS. Then, you only have one outstanding known issue with multiple test threads rather than two. In my view, I don't see the downside of merging this even if you don't remove --test-threads 1 from CI.

@spl spl force-pushed the serialize-env-tests branch from aa968a0 to d098048 Compare July 11, 2019 16:37
@spl
Copy link
Contributor Author

spl commented Jul 12, 2019

Okay, I think I've fixed all the test threads issues. The failures in the build results appear to be network-related.

@spl spl closed this Jul 12, 2019
@spl spl deleted the serialize-env-tests branch July 12, 2019 10:48
@spl spl restored the serialize-env-tests branch July 12, 2019 10:48
@spl spl reopened this Jul 12, 2019
@spl
Copy link
Contributor Author

spl commented Jul 12, 2019

Huh. I accidentally deleted the branch, which closed the PR. Then, I restored it and re-opened the PR. And that had the unexpected result of re-running the Azure build. 🤷‍♂

@alexcrichton alexcrichton merged commit fb1ae59 into rust-lang:master Jul 12, 2019
@spl spl deleted the serialize-env-tests branch July 12, 2019 19:36
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