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
19 changes: 17 additions & 2 deletions build_system/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,14 +835,18 @@ fn valid_ui_error_pattern_test(file: &str) -> bool {
}

fn contains_ui_error_patterns(file_path: &Path, keep_lto_tests: bool) -> Result<bool, String> {
// Tests generating errors.
// 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))?;

let mut has_pass_marker = false;
for line in BufReader::new(file).lines().map_while(Result::ok) {
let line = line.trim();
if line.is_empty() {
continue;
}

if [
"//@ error-pattern:",
"//@ build-fail",
Expand Down Expand Up @@ -870,16 +874,27 @@ fn contains_ui_error_patterns(file_path: &Path, keep_lto_tests: bool) -> Result<
if line.contains("//[") && line.contains("]~") {
return Ok(true);
}
// Check for pass markers
if ["//@ check-pass", "//@ build-pass", "//@ run-pass"]
.iter()
.any(|marker| line.contains(marker))
{
has_pass_marker = 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)

// If there are no error patterns, check for pass markers
// Keep tests with pass markers, remove tests without them
Ok(!has_pass_marker)
}

// # Parameters
Expand Down
Loading