From 7dd02fc4e6557f5713ac0cc0ddbf4aa6553e4ab5 Mon Sep 17 00:00:00 2001 From: Matej Hrica Date: Tue, 14 Jul 2026 13:47:59 +0200 Subject: [PATCH] tests/runner+Makefile: remove "all" special case, use "*" instead The glob matching introduced in the previous commit already handles "*" correctly, making the "all" special case redundant. Default to "*" and drop the separate code path and reserved name check. Assisted-by: OpenCode:claude-opus-4.6 Signed-off-by: Matej Hrica --- Makefile | 2 +- tests/runner/src/main.rs | 55 ++++++++++++++++--------------------- tests/test_cases/src/lib.rs | 3 -- 3 files changed, 25 insertions(+), 35 deletions(-) diff --git a/Makefile b/Makefile index 7b491f7..6351f79 100644 --- a/Makefile +++ b/Makefile @@ -267,7 +267,7 @@ test-prefix: test-prefix/$(LIBDIR_$(OS))/libkrun.pc fi endif -TEST ?= all +TEST ?= * TEST_FLAGS ?= # Extra library paths needed for tests (libkrunfw, llvm) diff --git a/tests/runner/src/main.rs b/tests/runner/src/main.rs index 306969a..6206932 100644 --- a/tests/runner/src/main.rs +++ b/tests/runner/src/main.rs @@ -357,37 +357,30 @@ fn run_tests( let mut results: Vec = Vec::new(); let all_tests = test_cases(); - let tests_to_run: Vec<_> = if test_case == "all" { - all_tests - } else { - let mut include: Vec = Vec::new(); - let mut exclude: Vec = Vec::new(); - for p in test_case.split(',').map(|p| p.trim()) { - if let Some(neg) = p.strip_prefix('!') { - exclude.push( - glob::Pattern::new(neg) - .with_context(|| format!("invalid glob pattern: {p}"))?, - ); - } else { - include.push( - glob::Pattern::new(p).with_context(|| format!("invalid glob pattern: {p}"))?, - ); - } - } - if include.is_empty() { - anyhow::bail!( - "No include patterns given (only exclusions). Use e.g. \"*,{test_case}\" to exclude." + let mut include: Vec = Vec::new(); + let mut exclude: Vec = Vec::new(); + for p in test_case.split(',').map(|p| p.trim()) { + if let Some(neg) = p.strip_prefix('!') { + exclude.push( + glob::Pattern::new(neg).with_context(|| format!("invalid glob pattern: {p}"))?, ); + } else { + include + .push(glob::Pattern::new(p).with_context(|| format!("invalid glob pattern: {p}"))?); } + } + if include.is_empty() { + anyhow::bail!( + "No include patterns given (only exclusions). Use e.g. \"*,{test_case}\" to exclude." + ); + } - all_tests - .into_iter() - .filter(|t| { - include.iter().any(|p| p.matches(t.name)) - && !exclude.iter().any(|p| p.matches(t.name)) - }) - .collect() - }; + let tests_to_run: Vec<_> = all_tests + .into_iter() + .filter(|t| { + include.iter().any(|p| p.matches(t.name)) && !exclude.iter().any(|p| p.matches(t.name)) + }) + .collect(); if tests_to_run.is_empty() { anyhow::bail!("No tests matched: {test_case}"); @@ -452,8 +445,8 @@ fn run_tests( #[derive(clap::Subcommand, Clone, Debug)] enum CliCommand { Test { - /// Test(s) to run: "all", a name, or comma-separated glob patterns (e.g. "net-*,!net-tap") - #[arg(long, default_value = "all")] + /// Test(s) to run: a name or comma-separated glob patterns (e.g. "net-*,!net-tap") + #[arg(long, default_value = "*")] test_case: String, /// Base directory for test artifacts #[arg(long)] @@ -476,7 +469,7 @@ enum CliCommand { impl Default for CliCommand { fn default() -> Self { Self::Test { - test_case: "all".to_string(), + test_case: "*".to_string(), base_dir: None, keep_all: false, github_summary: false, diff --git a/tests/test_cases/src/lib.rs b/tests/test_cases/src/lib.rs index e79a915..3d995cd 100644 --- a/tests/test_cases/src/lib.rs +++ b/tests/test_cases/src/lib.rs @@ -331,9 +331,6 @@ mod tests { panic!("test_cases() contains multiple items named `{name}`") } - if name == "all" { - panic!("test_cases() contains test named {name}, but the name is reseved") - } for c in ['*', '?', '[', ']', ',', '!'] { if name.contains(c) { panic!( -- 2.51.2