Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 13 additions & 33 deletions build_system/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,52 +834,32 @@ fn valid_ui_error_pattern_test(file: &str) -> bool {
.any(|to_ignore| file.ends_with(to_ignore))
}

fn contains_ui_error_patterns(file_path: &Path, keep_lto_tests: bool) -> Result<bool, String> {
// Tests generating errors.
fn contains_ui_error_patterns(file_path: &Path, _keep_lto_tests: bool) -> Result<bool, String> {
// Inverted logic: UI tests are expected to fail by default unless marked with pass markers.
// Return false (keep) for tests with pass markers, true (remove) for everything else.
let file = File::open(file_path)
.map_err(|error| format!("Failed to read `{}`: {:?}", file_path.display(), error))?;
for line in BufReader::new(file).lines().map_while(Result::ok) {
let line = line.trim();
if line.is_empty() {
continue;
}

// Check for pass markers - these tests should be kept (return false)
if [
"//@ error-pattern:",
"//@ build-fail",
"//@ run-fail",
"//@ known-bug",
"-Cllvm-args",
"//~",
"thread",
"//@ check-pass",
"//@ build-pass",
"//@ run-pass",
]
.iter()
.any(|check| line.contains(check))
.any(|marker| line.contains(marker))
{
return Ok(true);
return Ok(false);
}

if !keep_lto_tests
&& (line.contains("-Clto")
|| line.contains("-C lto")
|| line.contains("compile-flags: -Clinker-plugin-lto"))
&& !line.contains("-Clto=thin")
{
return Ok(true);
}

if line.contains("//[") && line.contains("]~") {
return Ok(true);
}
}
let file_path = file_path.display().to_string();
if file_path.contains("ambiguous-4-extern.rs") {
eprintln!("nothing found for {file_path:?}");
}
// The files in this directory contain errors.
if file_path.contains("/error-emitter/") {
return Ok(true);
}
Ok(false)

// Default: remove tests without pass markers (expected to fail by default)
Ok(true)
}

// # Parameters
Expand Down
Loading