From a135ced5ce76a842c85a9b62baccefc5e53fb31c Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Mon, 16 Mar 2020 14:53:22 +0100 Subject: [PATCH] Fix ui test blessing when a test has an empty stderr file after having had content there before the current changes --- src/tools/compiletest/src/runtest.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 61a7d8ee5c9..1dd5adb2209 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -3338,6 +3338,10 @@ impl<'test> TestCx<'test> { } fn delete_file(&self, file: &PathBuf) { + if !file.exists() { + // Deleting a nonexistant file would error. + return; + } if let Err(e) = fs::remove_file(file) { self.fatal(&format!("failed to delete `{}`: {}", file.display(), e,)); } @@ -3400,7 +3404,7 @@ impl<'test> TestCx<'test> { let examined_content = self.load_expected_output_from_path(&examined_path).unwrap_or_else(|_| String::new()); - if examined_path.exists() && canon_content == &examined_content { + if canon_content == &examined_content { self.delete_file(&examined_path); } }