]> git.lizzy.rs Git - rust.git/commitdiff
Disallow non-same compare-mode-nll
authorJack Huey <31162821+jackh726@users.noreply.github.com>
Sun, 22 May 2022 07:04:12 +0000 (03:04 -0400)
committerJack Huey <31162821+jackh726@users.noreply.github.com>
Mon, 23 May 2022 03:57:55 +0000 (23:57 -0400)
src/test/ui/json-multiple.nll.stderr [deleted file]
src/test/ui/json-multiple.rs
src/test/ui/json-options.nll.stderr [deleted file]
src/test/ui/json-options.rs
src/test/ui/rmeta/emit-artifact-notifications.nll.stderr [deleted file]
src/test/ui/rmeta/emit-artifact-notifications.rs
src/test/ui/save-analysis/emit-notifications.nll.stderr [deleted file]
src/test/ui/save-analysis/emit-notifications.rs
src/tools/compiletest/src/runtest.rs

diff --git a/src/test/ui/json-multiple.nll.stderr b/src/test/ui/json-multiple.nll.stderr
deleted file mode 100644 (file)
index c2cb8bc..0000000
+++ /dev/null
@@ -1 +0,0 @@
-{"artifact":"$TEST_BUILD_DIR/json-multiple.nll/libjson_multiple.rlib","emit":"link"}
index fb126339dc21665970c684a3075792ec7748881f..4c37e20d94dda0e9b3c59e886a1c0ad5dfb92dc5 100644 (file)
@@ -1,5 +1,6 @@
 // build-pass
 // ignore-pass (different metadata emitted in different modes)
 // compile-flags: --json=diagnostic-short --json artifacts --error-format=json
+// ignore-compare-mode-nll
 
 #![crate_type = "lib"]
diff --git a/src/test/ui/json-options.nll.stderr b/src/test/ui/json-options.nll.stderr
deleted file mode 100644 (file)
index f19a9cd..0000000
+++ /dev/null
@@ -1 +0,0 @@
-{"artifact":"$TEST_BUILD_DIR/json-options.nll/libjson_options.rlib","emit":"link"}
index 8b6ba131eb0021c0a7ce4515548c8faf49fdc954..fea07cc9e3e542cd089ee0f9e396878ced6dd361 100644 (file)
@@ -1,5 +1,6 @@
 // build-pass
 // ignore-pass (different metadata emitted in different modes)
 // compile-flags: --json=diagnostic-short,artifacts --error-format=json
+// ignore-compare-mode-nll
 
 #![crate_type = "lib"]
diff --git a/src/test/ui/rmeta/emit-artifact-notifications.nll.stderr b/src/test/ui/rmeta/emit-artifact-notifications.nll.stderr
deleted file mode 100644 (file)
index ed62f30..0000000
+++ /dev/null
@@ -1 +0,0 @@
-{"artifact":"$TEST_BUILD_DIR/rmeta/emit-artifact-notifications.nll/libemit_artifact_notifications.rmeta","emit":"metadata"}
index 984a7fabb6633ee8c750b69c46993dff237da645..be38fb4c3a69a31babcd5469ab0b91af1ee35b3a 100644 (file)
@@ -2,6 +2,7 @@
 // build-pass
 // ignore-pass
 // ^-- needed because `--pass check` does not emit the output needed.
+// ignore-compare-mode-nll
 
 // A very basic test for the emission of artifact notifications in JSON output.
 
diff --git a/src/test/ui/save-analysis/emit-notifications.nll.stderr b/src/test/ui/save-analysis/emit-notifications.nll.stderr
deleted file mode 100644 (file)
index 60734ce..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-{"artifact":"$TEST_BUILD_DIR/save-analysis/emit-notifications.nll/save-analysis/libemit_notifications.json","emit":"save-analysis"}
-{"artifact":"$TEST_BUILD_DIR/save-analysis/emit-notifications.nll/libemit_notifications.rlib","emit":"link"}
index 9179944a6201d62cd56e64e303f9473c62d2bc37..8a696695ec0a2faa1e3e0c234c2136f09ece0149 100644 (file)
@@ -3,5 +3,6 @@
 // compile-flags: --crate-type rlib --error-format=json
 // ignore-pass
 // ^-- needed because otherwise, the .stderr file changes with --pass check
+// ignore-compare-mode-nll
 
 pub fn foo() {}
index a59a0584d5e99245753b2d39621d534345af6d53..64b6df3567a4a07cd70f69d5956902726d67b08c 100644 (file)
@@ -3112,7 +3112,7 @@ fn run_ui_test(&self) {
         let expected_fixed = self.load_expected_output(UI_FIXED);
 
         let modes_to_prune = vec![CompareMode::Nll];
-        self.prune_duplicate_outputs(&modes_to_prune);
+        self.check_and_prune_duplicate_outputs(&proc_res, &[], &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);
@@ -3730,28 +3730,54 @@ fn compare_output(&self, kind: &str, actual: &str, expected: &str) -> usize {
         if self.config.bless { 0 } else { 1 }
     }
 
-    fn prune_duplicate_output(&self, mode: CompareMode, kind: &str, canon_content: &str) {
-        let examined_path = expected_output_path(&self.testpaths, self.revision, &Some(mode), kind);
-
-        let examined_content =
-            self.load_expected_output_from_path(&examined_path).unwrap_or_else(|_| String::new());
+    fn check_and_prune_duplicate_outputs(
+        &self,
+        proc_res: &ProcRes,
+        modes: &[CompareMode],
+        require_same_modes: &[CompareMode],
+    ) {
+        for kind in UI_EXTENSIONS {
+            let canon_comparison_path =
+                expected_output_path(&self.testpaths, self.revision, &None, kind);
 
-        if canon_content == examined_content {
-            self.delete_file(&examined_path);
-        }
-    }
+            let canon = match self.load_expected_output_from_path(&canon_comparison_path) {
+                Ok(canon) => canon,
+                _ => continue,
+            };
+            let bless = self.config.bless;
+            let check_and_prune_duplicate_outputs = |mode: &CompareMode, require_same: bool| {
+                let examined_path =
+                    expected_output_path(&self.testpaths, self.revision, &Some(mode.clone()), kind);
+
+                // If there is no output, there is nothing to do
+                let examined_content = match self.load_expected_output_from_path(&examined_path) {
+                    Ok(content) => content,
+                    _ => return,
+                };
 
-    fn prune_duplicate_outputs(&self, modes: &[CompareMode]) {
-        if self.config.bless {
-            for kind in UI_EXTENSIONS {
-                let canon_comparison_path =
-                    expected_output_path(&self.testpaths, self.revision, &None, kind);
+                let is_duplicate = canon == examined_content;
 
-                if let Ok(canon) = self.load_expected_output_from_path(&canon_comparison_path) {
-                    for mode in modes {
-                        self.prune_duplicate_output(mode.clone(), kind, &canon);
+                match (bless, require_same, is_duplicate) {
+                    // If we're blessing and the output is the same, then delete the file.
+                    (true, _, true) => {
+                        self.delete_file(&examined_path);
                     }
+                    // If we want them to be the same, but they are different, then error.
+                    // We do this wether we bless or not
+                    (_, true, false) => {
+                        self.fatal_proc_rec(
+                            &format!("`{}` should not have different output from base test!", kind),
+                            proc_res,
+                        );
+                    }
+                    _ => {}
                 }
+            };
+            for mode in modes {
+                check_and_prune_duplicate_outputs(mode, false);
+            }
+            for mode in require_same_modes {
+                check_and_prune_duplicate_outputs(mode, true);
             }
         }
     }