Skip to content

Commit

Permalink
allow KMT test regex for all or multiple packages (#33050)
Browse files Browse the repository at this point in the history
  • Loading branch information
brycekahle authored Jan 17, 2025
1 parent 3c42298 commit 6ce5f00
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 2 additions & 9 deletions tasks/kmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions test/new-e2e/system-probe/test-runner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 6ce5f00

Please sign in to comment.