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

This commit is contained in:
Erich Gubler committed 2025-10-21 12:48:24 -04:00
1 parent 0ef0754443
commit 337b9aa65f
1 file changed
+17 -8
+17 -8
View File
@@ -51,7 +51,7 @@ const CTS_DEFAULT_TEST_LIST: &str = "cts_runner/test.lst";
#[derive(Default)]
struct TestLine {
pub selector: OsString,
pub fails_if: Option<String>,
pub fails_if: Vec<String>,
}
pub fn run_cts(shell: Shell, mut args: Arguments) -> anyhow::Result<()> {
@@ -87,9 +87,11 @@ pub fn run_cts(shell: Shell, mut args: Arguments) -> anyhow::Result<()> {
for file in list_files {
tests.extend(shell.read_file(file)?.lines().filter_map(|line| {
static TEST_LINE_REGEX: LazyLock<Regex> = LazyLock::new(|| {
RegexBuilder::new(r#"(?:fails-if\s*\(\s*(?<fails_if>\w+)\s*\)\s+)?(?<selector>.*)"#)
.build()
.unwrap()
RegexBuilder::new(
r#"(?:fails-if\s*\(\s*(?<fails_if>\w+(?:,\w+)*?)\s*\)\s+)?(?<selector>.*)"#,
)
.build()
.unwrap()
});
let trimmed = line.trim();
@@ -99,7 +101,15 @@ pub fn run_cts(shell: Shell, mut args: Arguments) -> anyhow::Result<()> {
.expect("Invalid test line: {trimmed}");
(!trimmed.is_empty() && !is_comment).then(|| TestLine {
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(),
})
}))
}
@@ -208,8 +218,8 @@ pub fn run_cts(shell: Shell, mut args: Arguments) -> anyhow::Result<()> {
log::info!("Running CTS");
for test in &tests {
match (&test.fails_if, &running_on_backend) {
(Some(backend), Some(running_on_backend)) if backend == running_on_backend => {
if let Some(running_on_backend) = &running_on_backend {
if test.fails_if.contains(running_on_backend) {
log::info!(
"Skipping {} on {} backend",
test.selector.to_string_lossy(),
@@ -217,7 +227,6 @@ pub fn run_cts(shell: Shell, mut args: Arguments) -> anyhow::Result<()> {
);
continue;
}
_ => {}
}
log::info!("Running {}", test.selector.to_string_lossy());