Skip to content

Conversation

@jamadeo
Copy link

@jamadeo jamadeo commented Oct 30, 2025

Adds a new lint to check for use of std::env::set_var in unit tests.

In our experience in https://github.com/block/goose, setting environment variables in tests has been the largest source of test flakiness. Test authors often think that if they properly clean up the mutated variable, all is well. But because tests run concurrently, there is really no way to isolate this effect other than marking them using e.g. https://crates.io/crates/serial_test.

changelog: [set_env_in_tests]: checks for use of std::env::set_var in unit tests

@rustbot rustbot added needs-fcp S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Oct 30, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 30, 2025

r? @Jarcho

rustbot has assigned @Jarcho.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@jamadeo jamadeo changed the title No env in tests Add a new lint to check for use of std::env::set_var in tests Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-fcp S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants