compiletest: Don't update PDB files of test cases in-place.

This commit is contained in:
Michael Woerister 2022-03-03 12:34:38 +01:00
parent 3ad299aa67
commit abe854f985

View File

@ -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) {