diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2023-06-12 18:07:04 +1000 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2023-06-28 11:08:09 +1000 |
| commit | 5b51d9cadb0a91e337b3a2e624e038eedcd0f529 (patch) | |
| tree | 07c5fe9b24c1d7526e6fa74932e3045a3492fcfe | |
| parent | d8d09b06815b14badfa9940f7bfc2a3ff5698ac6 (diff) | |
| download | rust-5b51d9cadb0a91e337b3a2e624e038eedcd0f529.tar.gz rust-5b51d9cadb0a91e337b3a2e624e038eedcd0f529.zip | |
Extract a common function for setting up environment vars
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 5c8ee7895d3..4439d60ac06 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1598,7 +1598,15 @@ impl<'test> TestCx<'test> { } fn exec_compiled_test(&self) -> ProcRes { - let env = &self.props.exec_env; + let prepare_env = |cmd: &mut Command| { + for key in &self.props.unset_exec_env { + cmd.env_remove(key); + } + + for (key, val) in &self.props.exec_env { + cmd.env(key, val); + } + }; let proc_res = match &*self.config.target { // This is pretty similar to below, we're transforming: @@ -1635,10 +1643,7 @@ impl<'test> TestCx<'test> { .args(support_libs) .args(args); - for key in &self.props.unset_exec_env { - test_client.env_remove(key); - } - test_client.envs(env.clone()); + prepare_env(&mut test_client); self.compose_and_run( test_client, @@ -1653,10 +1658,7 @@ impl<'test> TestCx<'test> { let mut wr_run = Command::new("wr-run"); wr_run.args(&[&prog]).args(args); - for key in &self.props.unset_exec_env { - wr_run.env_remove(key); - } - wr_run.envs(env.clone()); + prepare_env(&mut wr_run); self.compose_and_run( wr_run, @@ -1671,10 +1673,7 @@ impl<'test> TestCx<'test> { let mut program = Command::new(&prog); program.args(args).current_dir(&self.output_base_dir()); - for key in &self.props.unset_exec_env { - program.env_remove(key); - } - program.envs(env.clone()); + prepare_env(&mut program); self.compose_and_run( program, |
