Skip to content

Commit aa0bd84

Browse files
committed
Fix rustfmt check failure
updated ui error pattern check logic formatted code added new condition code formated removed unwanted comment removed unwanted file
1 parent 789ce5c commit aa0bd84

File tree

1 file changed

+46
-10
lines changed

1 file changed

+46
-10
lines changed

build_system/src/test.rs

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -834,32 +834,68 @@ fn valid_ui_error_pattern_test(file: &str) -> bool {
834834
.any(|to_ignore| file.ends_with(to_ignore))
835835
}
836836

837-
fn contains_ui_error_patterns(file_path: &Path, _keep_lto_tests: bool) -> Result<bool, String> {
838-
// Inverted logic: UI tests are expected to fail by default unless marked with pass markers.
839-
// Return false (keep) for tests with pass markers, true (remove) for everything else.
837+
fn contains_ui_error_patterns(file_path: &Path, keep_lto_tests: bool) -> Result<bool, String> {
840838
let file = File::open(file_path)
841839
.map_err(|error| format!("Failed to read `{}`: {:?}", file_path.display(), error))?;
840+
841+
let mut has_pass_marker = false;
842842
for line in BufReader::new(file).lines().map_while(Result::ok) {
843843
let line = line.trim();
844844
if line.is_empty() {
845845
continue;
846846
}
847847

848-
// Check for pass markers - these tests should be kept (return false)
849848
if [
850-
"//@ check-pass",
851-
"//@ build-pass",
852-
"//@ run-pass",
849+
"//@ error-pattern:",
850+
"//@ build-fail",
851+
"//@ run-fail",
852+
"//@ known-bug",
853+
"-Cllvm-args",
854+
"//~",
855+
"thread",
853856
]
854857
.iter()
855-
.any(|marker| line.contains(marker))
858+
.any(|check| line.contains(check))
859+
{
860+
return Ok(true);
861+
}
862+
863+
if !keep_lto_tests
864+
&& (line.contains("-Clto")
865+
|| line.contains("-C lto")
866+
|| line.contains("compile-flags: -Clinker-plugin-lto"))
867+
&& !line.contains("-Clto=thin")
868+
{
869+
return Ok(true);
870+
}
871+
872+
if line.contains("//[") && line.contains("]~") {
873+
return Ok(true);
874+
}
875+
876+
// Check for pass markers
877+
if ["//@ check-pass", "//@ build-pass", "//@ run-pass"]
878+
.iter()
879+
.any(|marker| line.contains(marker))
856880
{
881+
has_pass_marker = true;
882+
}
883+
884+
if ["//@ ignore-auxiliary"].iter().any(|marker| line.contains(marker)) {
857885
return Ok(false);
858886
}
859887
}
888+
let file_path = file_path.display().to_string();
889+
if file_path.contains("ambiguous-4-extern.rs") {
890+
eprintln!("nothing found for {file_path:?}");
891+
}
892+
893+
// The files in this directory contain errors.
894+
if file_path.contains("/error-emitter/") {
895+
return Ok(true);
896+
}
860897

861-
// Default: remove tests without pass markers (expected to fail by default)
862-
Ok(true)
898+
Ok(!has_pass_marker)
863899
}
864900

865901
// # Parameters

0 commit comments

Comments
 (0)