about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo>2022-03-03 12:34:38 +0100
committerMichael Woerister <michaelwoerister@posteo>2022-03-14 16:52:47 +0100
commitabe854f9850f281889b76c76265dbe4178aa8c5f (patch)
tree6ebb1c64c33140b559ecb69f884115b20ddef43e
parent3ad299aa670face2085d2abec6e8481fa582068a (diff)
downloadrust-abe854f9850f281889b76c76265dbe4178aa8c5f.tar.gz
rust-abe854f9850f281889b76c76265dbe4178aa8c5f.zip
compiletest: Don't update PDB files of test cases in-place.
-rw-r--r--src/tools/compiletest/src/runtest.rs57
1 files changed, 48 insertions, 9 deletions
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 8431aa7b818..cf9f5e1332f 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -263,11 +263,19 @@ impl<'test> TestCx<'test> {
             Ui | MirOpt => false,
             mode => panic!("unimplemented for mode {:?}", mode),
         };
-        if test_should_run { self.run_if_enabled() } else { WillExecute::No }
+        if test_should_run {
+            self.run_if_enabled()
+        } else {
+            WillExecute::No
+        }
     }
 
     fn run_if_enabled(&self) -> WillExecute {
-        if self.config.run_enabled() { WillExecute::Yes } else { WillExecute::Disabled }
+        if self.config.run_enabled() {
+            WillExecute::Yes
+        } else {
+            WillExecute::Disabled
+        }
     }
 
     fn should_run_successfully(&self, pm: Option<PassMode>) -> bool {
@@ -661,6 +669,19 @@ impl<'test> TestCx<'test> {
     }
 
     fn run_debuginfo_cdb_test_no_opt(&self) {
+        let exe_file = self.make_exe_name();
+
+        // Existing PDB files are update in-place. When changing the debuginfo
+        // the compiler generates for something, this can lead to the situation
+        // where both the old and the new version of the debuginfo for the same
+        // type is present in the PDB, which is very confusing.
+        // Therefore we delete any existing PDB file before compiling the test
+        // case.
+        let pdb_file = exe_file.with_extension(".pdb");
+        if pdb_file.exists() {
+            std::fs::remove_file(pdb_file).unwrap();
+        }
+
         // compile test file (it should have 'compile-flags:-g' in the header)
         let should_run = self.run_if_enabled();
         let compile_result = self.compile_test(should_run, EmitMetadata::No);
@@ -671,8 +692,6 @@ impl<'test> TestCx<'test> {
             return;
         }
 
-        let exe_file = self.make_exe_name();
-
         let prefixes = {
             static PREFIXES: &[&str] = &["cdb", "cdbg"];
             // No "native rust support" variation for CDB yet.
@@ -2010,7 +2029,11 @@ impl<'test> TestCx<'test> {
             Some(ref s) => s
                 .split(' ')
                 .filter_map(|s| {
-                    if s.chars().all(|c| c.is_whitespace()) { None } else { Some(s.to_owned()) }
+                    if s.chars().all(|c| c.is_whitespace()) {
+                        None
+                    } else {
+                        Some(s.to_owned())
+                    }
                 })
                 .collect(),
             None => Vec::new(),
@@ -2069,7 +2092,11 @@ impl<'test> TestCx<'test> {
     /// The revision, ignored for incremental compilation since it wants all revisions in
     /// the same directory.
     fn safe_revision(&self) -> Option<&str> {
-        if self.config.mode == Incremental { None } else { self.revision }
+        if self.config.mode == Incremental {
+            None
+        } else {
+            self.revision
+        }
     }
 
     /// Gets the absolute path to the directory where all output for the given
@@ -2224,7 +2251,11 @@ impl<'test> TestCx<'test> {
 
     fn charset() -> &'static str {
         // FreeBSD 10.1 defaults to GDB 6.1.1 which doesn't support "auto" charset
-        if cfg!(target_os = "freebsd") { "ISO-8859-1" } else { "UTF-8" }
+        if cfg!(target_os = "freebsd") {
+            "ISO-8859-1"
+        } else {
+            "UTF-8"
+        }
     }
 
     fn run_rustdoc_test(&self) {
@@ -3014,7 +3045,11 @@ impl<'test> TestCx<'test> {
         let (stderr_kind, stdout_kind) = match output_kind {
             TestOutput::Compile => (
                 {
-                    if self.props.stderr_per_bitwidth { &stderr_bits } else { UI_STDERR }
+                    if self.props.stderr_per_bitwidth {
+                        &stderr_bits
+                    } else {
+                        UI_STDERR
+                    }
                 },
                 UI_STDOUT,
             ),
@@ -3711,7 +3746,11 @@ impl<'test> TestCx<'test> {
         for output_file in files {
             println!("Actual {} saved to {}", kind, output_file.display());
         }
-        if self.config.bless { 0 } else { 1 }
+        if self.config.bless {
+            0
+        } else {
+            1
+        }
     }
 
     fn prune_duplicate_output(&self, mode: CompareMode, kind: &str, canon_content: &str) {