Skip to content

Commit e4990a8

Browse files
cmd-kola: add testiso to run iso.* translation wrapper
Add translate_testiso_args() function to convert legacy 'kola testiso' command to new 'kola run iso.*' format. The function: - Replaces 'testiso' with 'run' - Adds '--parallel 4' by default if not specified - Properly handles flags that take values (--denylist-test, --tag, etc.)
1 parent 36269c0 commit e4990a8

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

src/cmd-kola

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,54 @@ from cosalib import cmdlib
1919

2020
basearch = cmdlib.get_basearch()
2121

22+
23+
def translate_testiso_args(kolaargs, subargs, unknown_args) -> bool:
24+
"""
25+
Translate legacy 'kola testiso' command to 'kola run iso.*' format.
26+
Modifies kolaargs in place.
27+
"""
28+
if not subargs or subargs[0] != 'testiso':
29+
return False
30+
31+
# Find and replace 'testiso' with 'run'
32+
testiso_idx = kolaargs.index('testiso')
33+
kolaargs[testiso_idx] = 'run'
34+
35+
# Collect test patterns from unknown_args (non-flag arguments)
36+
# Need to skip flag values by tracking when we see a flag that takes a value
37+
test_patterns = []
38+
skip_next = False
39+
flags_with_values = {'--denylist-test', '--tag', '--platform', '-p', '--parallel', '-j'}
40+
41+
for arg in unknown_args:
42+
if skip_next:
43+
skip_next = False
44+
continue
45+
if arg.startswith('-'):
46+
# Check if this flag takes a value
47+
if any(arg.startswith(f) for f in flags_with_values):
48+
skip_next = True
49+
continue
50+
# This is a test pattern
51+
test_patterns.append(arg)
52+
53+
if not test_patterns:
54+
# No test pattern specified, default to all iso tests
55+
kolaargs.append('iso.*')
56+
else:
57+
# Prepend 'iso.' to test patterns if not already present
58+
for i in range(testiso_idx + 1, len(kolaargs)):
59+
arg = kolaargs[i]
60+
# Add 'iso.' prefix if this is a test pattern and doesn't have it
61+
if arg in test_patterns and not arg.startswith('iso.'):
62+
kolaargs[i] = f'iso.{arg}'
63+
64+
# Add parallel flag if not already specified
65+
if not any(arg in kolaargs for arg in ['--parallel', '-j']):
66+
kolaargs.extend(['--parallel', '4'])
67+
return True
68+
69+
2270
# Parse args and dispatch
2371
parser = argparse.ArgumentParser()
2472
parser.add_argument("--build", help="Build ID")
@@ -54,6 +102,10 @@ subargs = args.subargs or [default_cmd]
54102
kolaargs.extend(subargs)
55103
kolaargs.extend(unknown_args)
56104

105+
# ISO tests were not part of kola before, so denylist by default to match old behavior.
106+
# Allow via legacy "kola testiso" command or explicit "iso.*" patterns.
107+
if not translate_testiso_args(kolaargs, subargs, unknown_args) and not any(arg.startswith('iso.') for arg in kolaargs):
108+
kolaargs.extend(['--denylist-test', 'iso.*'])
57109

58110
if args.upgrades:
59111
kolaargs.extend(['--output-dir', outputdir])

0 commit comments

Comments
 (0)