Skip to content

Commit b90142a

Browse files
Googlercopybara-github
authored andcommitted
Call Command::env_clear() in integration tests to improve test hermeticity.
The integration tests each run by creating `Command` sub-processes, and they expect capturing behavior by looking only at stdout output. Environmental variables such as `RUST_TEST_NOCAPTURE`, however, can change this behavior. To improve test hermeticity, we adjust the integration test runner so it uses a clean environment for the child sub-processes. PiperOrigin-RevId: 728732692
1 parent f48d438 commit b90142a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

integration_tests/src/integration_tests.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2012,7 +2012,12 @@ mod tests {
20122012
"./{}/debug/{name}",
20132013
std::env::var("CARGO_TARGET_DIR").unwrap_or_else(|_| "target".into())
20142014
);
2015-
Command::new(command_path)
2015+
let mut command = Command::new(command_path);
2016+
// For test hermeticity, clear the env. Integration testing
2017+
// depends on implicit output capturing (RUST_TEST_NOCAPTURE
2018+
// should be unset or set to "0").
2019+
command.env_clear();
2020+
command
20162021
}
20172022

20182023
fn execute_sharded_test(process: &'static str, shard: u64, total_shards: u64) -> Result<bool> {

0 commit comments

Comments
 (0)