Skip to content

Commit 4edba55

Browse files
committed
add support for // unset-exec-env in compiletest
1 parent 2bf5f77 commit 4edba55

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

src/tools/compiletest/src/header.rs

+11
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ pub struct TestProps {
9090
pub unset_rustc_env: Vec<String>,
9191
// Environment settings to use during execution
9292
pub exec_env: Vec<(String, String)>,
93+
// Environment variables to unset prior to execution.
94+
// Variables are unset before applying 'exec_env'
95+
pub unset_exec_env: Vec<String>,
9396
// Build documentation for all specified aux-builds as well
9497
pub build_aux_docs: bool,
9598
// Flag to force a crate to be built with the host architecture
@@ -198,6 +201,7 @@ mod directives {
198201
pub const AUX_CRATE: &'static str = "aux-crate";
199202
pub const EXEC_ENV: &'static str = "exec-env";
200203
pub const RUSTC_ENV: &'static str = "rustc-env";
204+
pub const UNSET_EXEC_ENV: &'static str = "unset-exec-env";
201205
pub const UNSET_RUSTC_ENV: &'static str = "unset-rustc-env";
202206
pub const FORBID_OUTPUT: &'static str = "forbid-output";
203207
pub const CHECK_TEST_LINE_NUMBERS_MATCH: &'static str = "check-test-line-numbers-match";
@@ -231,6 +235,7 @@ impl TestProps {
231235
rustc_env: vec![],
232236
unset_rustc_env: vec![],
233237
exec_env: vec![],
238+
unset_exec_env: vec![],
234239
build_aux_docs: false,
235240
force_host: false,
236241
check_stdout: false,
@@ -382,6 +387,12 @@ impl TestProps {
382387
&mut self.exec_env,
383388
Config::parse_env,
384389
);
390+
config.push_name_value_directive(
391+
ln,
392+
UNSET_EXEC_ENV,
393+
&mut self.unset_exec_env,
394+
|r| r,
395+
);
385396
config.push_name_value_directive(
386397
ln,
387398
RUSTC_ENV,

src/tools/compiletest/src/runtest.rs

+21-4
Original file line numberDiff line numberDiff line change
@@ -1613,8 +1613,13 @@ impl<'test> TestCx<'test> {
16131613
test_client
16141614
.args(&["run", &support_libs.len().to_string(), &prog])
16151615
.args(support_libs)
1616-
.args(args)
1617-
.envs(env.clone());
1616+
.args(args);
1617+
1618+
for key in &self.props.unset_exec_env {
1619+
test_client.env_remove(key);
1620+
}
1621+
test_client.envs(env.clone());
1622+
16181623
self.compose_and_run(
16191624
test_client,
16201625
self.config.run_lib_path.to_str().unwrap(),
@@ -1626,7 +1631,13 @@ impl<'test> TestCx<'test> {
16261631
let aux_dir = self.aux_output_dir_name();
16271632
let ProcArgs { prog, args } = self.make_run_args();
16281633
let mut wr_run = Command::new("wr-run");
1629-
wr_run.args(&[&prog]).args(args).envs(env.clone());
1634+
wr_run.args(&[&prog]).args(args);
1635+
1636+
for key in &self.props.unset_exec_env {
1637+
wr_run.env_remove(key);
1638+
}
1639+
wr_run.envs(env.clone());
1640+
16301641
self.compose_and_run(
16311642
wr_run,
16321643
self.config.run_lib_path.to_str().unwrap(),
@@ -1638,7 +1649,13 @@ impl<'test> TestCx<'test> {
16381649
let aux_dir = self.aux_output_dir_name();
16391650
let ProcArgs { prog, args } = self.make_run_args();
16401651
let mut program = Command::new(&prog);
1641-
program.args(args).current_dir(&self.output_base_dir()).envs(env.clone());
1652+
program.args(args).current_dir(&self.output_base_dir());
1653+
1654+
for key in &self.props.unset_exec_env {
1655+
program.env_remove(key);
1656+
}
1657+
program.envs(env.clone());
1658+
16421659
self.compose_and_run(
16431660
program,
16441661
self.config.run_lib_path.to_str().unwrap(),

0 commit comments

Comments
 (0)