diff --git a/build_system/src/test.rs b/build_system/src/test.rs index ca2a2a7dc2d..6f462daad14 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -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 { - // 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", @@ -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