]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/compiletest/src/runtest.rs
Always pass `-Z future-incompat-report` to UI tests
[rust.git] / src / tools / compiletest / src / runtest.rs
index acad316d807a3512e62e687a633712ff7842ab41..19ddcf3a01091d5decb2d094b33e7b29c1054349 100644 (file)
@@ -1775,6 +1775,11 @@ fn build_auxiliary(&self, source_path: &str, aux_dir: &Path) -> bool {
         let mut aux_rustc =
             aux_cx.make_compile_args(input_file, aux_output, EmitMetadata::No, AllowUnused::No);
 
+        for key in &aux_props.unset_rustc_env {
+            aux_rustc.env_remove(key);
+        }
+        aux_rustc.envs(aux_props.rustc_env.clone());
+
         let (dylib, crate_type) = if aux_props.no_prefer_dynamic {
             (true, None)
         } else if self.config.target.contains("cloudabi")
@@ -1937,6 +1942,7 @@ fn make_compile_args(
                 }
                 rustc.arg("-Zui-testing");
                 rustc.arg("-Zdeduplicate-diagnostics=no");
+                rustc.arg("-Zemit-future-incompat-report");
             }
             MirOpt => {
                 rustc.args(&[
@@ -2973,6 +2979,7 @@ fn run_ui_test(&self) {
         self.prune_duplicate_outputs(&modes_to_prune);
 
         let mut errors = self.load_compare_outputs(&proc_res, TestOutput::Compile, explicit);
+        let rustfix_input = json::rustfix_diagnostics_only(&proc_res.stderr);
 
         if self.config.compare_mode.is_some() {
             // don't test rustfix with nll right now
@@ -2983,7 +2990,7 @@ fn run_ui_test(&self) {
             // This will return an empty `Vec` in case the executed test file has a
             // `compile-flags: --error-format=xxxx` header with a value other than `json`.
             let suggestions = get_suggestions_from_json(
-                &proc_res.stderr,
+                &rustfix_input,
                 &HashSet::new(),
                 Filter::MachineApplicableOnly,
             )
@@ -3010,7 +3017,7 @@ fn run_ui_test(&self) {
             // Apply suggestions from rustc to the code itself
             let unfixed_code = self.load_expected_output_from_path(&self.testpaths.file).unwrap();
             let suggestions = get_suggestions_from_json(
-                &proc_res.stderr,
+                &rustfix_input,
                 &HashSet::new(),
                 if self.props.rustfix_only_machine_applicable {
                     Filter::MachineApplicableOnly
@@ -3116,7 +3123,9 @@ fn run_ui_test(&self) {
                 self.fatal_proc_rec("failed to compile fixed code", &res);
             }
             if !res.stderr.is_empty() && !self.props.rustfix_only_machine_applicable {
-                self.fatal_proc_rec("fixed code is still producing diagnostics", &res);
+                if !json::rustfix_diagnostics_only(&res.stderr).is_empty() {
+                    self.fatal_proc_rec("fixed code is still producing diagnostics", &res);
+                }
             }
         }
     }
@@ -3199,8 +3208,18 @@ fn check_mir_dump(&self) {
                     from_file = format!("{}.{}.mir", test_name, first_pass);
                     to_file = Some(second_file);
                 } else {
-                    expected_file =
-                        format!("{}{}.mir", test_name.trim_end_matches(".mir"), bit_width);
+                    let ext_re = Regex::new(r#"(\.(mir|dot|html))$"#).unwrap();
+                    let cap = ext_re
+                        .captures_iter(test_name)
+                        .next()
+                        .expect("test_name has an invalid extension");
+                    let extension = cap.get(1).unwrap().as_str();
+                    expected_file = format!(
+                        "{}{}{}",
+                        test_name.trim_end_matches(extension),
+                        bit_width,
+                        extension,
+                    );
                     from_file = test_name.to_string();
                     assert!(
                         test_names.next().is_none(),