test(cts): allow comma-separated backend list in fails-if(…)

This commit is contained in:
Erich Gubler 2025-09-25 14:04:53 -04:00
parent 5cbab61109
commit 83a0722eb6

View File

@ -53,7 +53,7 @@ const CTS_DEFAULT_TEST_LIST: &str = "cts_runner/test.lst";
#[derive(Default)] #[derive(Default)]
struct TestLine { struct TestLine {
pub selector: OsString, pub selector: OsString,
pub fails_if: Option<String>, pub fails_if: Vec<String>,
} }
pub fn run_cts( pub fn run_cts(
@ -98,7 +98,9 @@ pub fn run_cts(
for file in list_files { for file in list_files {
tests.extend(shell.read_file(file)?.lines().filter_map(|line| { tests.extend(shell.read_file(file)?.lines().filter_map(|line| {
static TEST_LINE_REGEX: LazyLock<Regex> = LazyLock::new(|| { static TEST_LINE_REGEX: LazyLock<Regex> = LazyLock::new(|| {
RegexBuilder::new(r#"(?:fails-if\s*\(\s*(?<fails_if>\w+)\s*\)\s+)?(?<selector>.*)"#) RegexBuilder::new(
r#"(?:fails-if\s*\(\s*(?<fails_if>\w+(?:,\w+)*?)\s*\)\s+)?(?<selector>.*)"#,
)
.build() .build()
.unwrap() .unwrap()
}); });
@ -110,7 +112,15 @@ pub fn run_cts(
.expect("Invalid test line: {trimmed}"); .expect("Invalid test line: {trimmed}");
(!trimmed.is_empty() && !is_comment).then(|| TestLine { (!trimmed.is_empty() && !is_comment).then(|| TestLine {
selector: OsString::from(&captures["selector"]), selector: OsString::from(&captures["selector"]),
fails_if: captures.name("fails_if").map(|m| m.as_str().to_string()), fails_if: captures
.name("fails_if")
.map(|m| {
m.as_str()
.split_terminator(',')
.map(|m| m.to_string())
.collect()
})
.unwrap_or_default(),
}) })
})) }))
} }
@ -237,8 +247,8 @@ pub fn run_cts(
log::info!("Running CTS"); log::info!("Running CTS");
for test in &tests { for test in &tests {
match (&test.fails_if, &running_on_backend) { if let Some(running_on_backend) = &running_on_backend {
(Some(backend), Some(running_on_backend)) if backend == running_on_backend => { if test.fails_if.contains(running_on_backend) {
log::info!( log::info!(
"Skipping {} on {} backend", "Skipping {} on {} backend",
test.selector.to_string_lossy(), test.selector.to_string_lossy(),
@ -246,7 +256,6 @@ pub fn run_cts(
); );
continue; continue;
} }
_ => {}
} }
log::info!("Running {}", test.selector.to_string_lossy()); log::info!("Running {}", test.selector.to_string_lossy());