From 6ce5f0040cbb506031834320ae64eff47b424a57 Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Fri, 17 Jan 2025 11:50:26 -0800 Subject: [PATCH] allow KMT test regex for all or multiple packages (#33050) --- tasks/kmt.py | 11 ++--------- test/new-e2e/system-probe/test-runner/main.go | 6 ++++++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/tasks/kmt.py b/tasks/kmt.py index 31ff0c39404421..5a8cdf588200dc 100644 --- a/tasks/kmt.py +++ b/tasks/kmt.py @@ -874,11 +874,10 @@ def build_run_config(run: str | None, packages: list[str]): c: dict[str, Any] = {} if len(packages) == 0: - return {"filters": {"*": {"exclude": False}}} + packages = ["*"] for p in packages: - if p[:2] == "./": - p = p[2:] + p = p.removeprefix("./") if run is not None: c["filters"] = {p: {"run-only": [run]}} else: @@ -1202,16 +1201,10 @@ def test( info(f"[+] Preparing {component} for {arch}") _prepare(ctx, stack, component, arch, packages=packages, verbose=verbose, domains=domains) - if run is not None and packages is None: - raise Exit("Package must be provided when specifying test") - pkgs = [] if packages is not None: pkgs = [os.path.relpath(os.path.realpath(p)) for p in go_package_dirs(packages.split(","), [NPM_TAG, BPF_TAG])] - if run is not None and len(pkgs) > 1: - raise Exit("Only a single package can be specified when running specific tests") - paths = KMTPaths(stack, Arch.local()) # Arch is not relevant to the test result paths, which is what we want now shutil.rmtree(paths.test_results, ignore_errors=True) # Reset test-results folder diff --git a/test/new-e2e/system-probe/test-runner/main.go b/test/new-e2e/system-probe/test-runner/main.go index a00f71a36a4137..7ab42cca682343 100644 --- a/test/new-e2e/system-probe/test-runner/main.go +++ b/test/new-e2e/system-probe/test-runner/main.go @@ -158,9 +158,15 @@ func buildCommandArgs(pkg string, xmlpath string, jsonpath string, testArgs []st if config, ok := packagesRunConfig[pkg]; ok && config.RunOnly != nil { args = append(args, "-test.run", strings.Join(config.RunOnly, "|")) } + if config, ok := packagesRunConfig[matchAllPackages]; ok && config.RunOnly != nil { + args = append(args, "-test.run", strings.Join(config.RunOnly, "|")) + } if config, ok := packagesRunConfig[pkg]; ok && config.Skip != nil { args = append(args, "-test.skip", strings.Join(config.Skip, "|")) } + if config, ok := packagesRunConfig[matchAllPackages]; ok && config.Skip != nil { + args = append(args, "-test.skip", strings.Join(config.Skip, "|")) + } return args }