diff options
author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-04-29 15:51:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-29 15:51:15 +0200 |
commit | 957a6ad4d9d51781962f53bc448136067df275fb (patch) | |
tree | bfc080aa4adb66e21782bd1dd78888b772603fff /src/tools/compiletest | |
parent | 825bc606f5d27e66c573db96d85eec907755f1ed (diff) | |
parent | dc9452207246594ef0d4221b332d218f86750d10 (diff) | |
download | rust-957a6ad4d9d51781962f53bc448136067df275fb.tar.gz |
Rollup merge of #110644 - pietroalbini:pa-json-formatting-tests, r=Mark-Simulacrum
Update tests for libtest `--format json`
This PR makes the test work on beta and stable, and adds a test ensuring the option is not available on beta and stable. Backported these commits from https://github.com/rust-lang/rust/pull/110414.
Diffstat (limited to 'src/tools/compiletest')
-rw-r--r-- | src/tools/compiletest/src/header.rs | 11 | ||||
-rw-r--r-- | src/tools/compiletest/src/header/cfg.rs | 6 | ||||
-rw-r--r-- | src/tools/compiletest/src/runtest.rs | 25 |
3 files changed, 37 insertions, 5 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 01da5981015..8cc935e54d1 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -90,6 +90,9 @@ pub struct TestProps { pub unset_rustc_env: Vec<String>, // Environment settings to use during execution pub exec_env: Vec<(String, String)>, + // Environment variables to unset prior to execution. + // Variables are unset before applying 'exec_env' + pub unset_exec_env: Vec<String>, // Build documentation for all specified aux-builds as well pub build_aux_docs: bool, // Flag to force a crate to be built with the host architecture @@ -198,6 +201,7 @@ mod directives { pub const AUX_CRATE: &'static str = "aux-crate"; pub const EXEC_ENV: &'static str = "exec-env"; pub const RUSTC_ENV: &'static str = "rustc-env"; + pub const UNSET_EXEC_ENV: &'static str = "unset-exec-env"; pub const UNSET_RUSTC_ENV: &'static str = "unset-rustc-env"; pub const FORBID_OUTPUT: &'static str = "forbid-output"; pub const CHECK_TEST_LINE_NUMBERS_MATCH: &'static str = "check-test-line-numbers-match"; @@ -231,6 +235,7 @@ impl TestProps { rustc_env: vec![], unset_rustc_env: vec![], exec_env: vec![], + unset_exec_env: vec![], build_aux_docs: false, force_host: false, check_stdout: false, @@ -384,6 +389,12 @@ impl TestProps { ); config.push_name_value_directive( ln, + UNSET_EXEC_ENV, + &mut self.unset_exec_env, + |r| r, + ); + config.push_name_value_directive( + ln, RUSTC_ENV, &mut self.rustc_env, Config::parse_env, diff --git a/src/tools/compiletest/src/header/cfg.rs b/src/tools/compiletest/src/header/cfg.rs index a9694d4d52c..86a749b935d 100644 --- a/src/tools/compiletest/src/header/cfg.rs +++ b/src/tools/compiletest/src/header/cfg.rs @@ -165,11 +165,15 @@ pub(super) fn parse_cfg_name_directive<'a>( message: "when the architecture is part of the Thumb family" } + // Technically the locally built compiler uses the "dev" channel rather than the "nightly" + // channel, even though most people don't know or won't care about it. To avoid confusion, we + // treat the "dev" channel as the "nightly" channel when processing the directive. condition! { - name: &config.channel, + name: if config.channel == "dev" { "nightly" } else { &config.channel }, allowed_names: &["stable", "beta", "nightly"], message: "when the release channel is {name}", } + condition! { name: "cross-compile", condition: config.target != config.host, diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index e03a73c4e71..0fd9f3ae3f4 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1614,8 +1614,13 @@ impl<'test> TestCx<'test> { test_client .args(&["run", &support_libs.len().to_string(), &prog]) .args(support_libs) - .args(args) - .envs(env.clone()); + .args(args); + + for key in &self.props.unset_exec_env { + test_client.env_remove(key); + } + test_client.envs(env.clone()); + self.compose_and_run( test_client, self.config.run_lib_path.to_str().unwrap(), @@ -1627,7 +1632,13 @@ impl<'test> TestCx<'test> { let aux_dir = self.aux_output_dir_name(); let ProcArgs { prog, args } = self.make_run_args(); let mut wr_run = Command::new("wr-run"); - wr_run.args(&[&prog]).args(args).envs(env.clone()); + wr_run.args(&[&prog]).args(args); + + for key in &self.props.unset_exec_env { + wr_run.env_remove(key); + } + wr_run.envs(env.clone()); + self.compose_and_run( wr_run, self.config.run_lib_path.to_str().unwrap(), @@ -1639,7 +1650,13 @@ impl<'test> TestCx<'test> { let aux_dir = self.aux_output_dir_name(); let ProcArgs { prog, args } = self.make_run_args(); let mut program = Command::new(&prog); - program.args(args).current_dir(&self.output_base_dir()).envs(env.clone()); + 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()); + self.compose_and_run( program, self.config.run_lib_path.to_str().unwrap(), |