Skip to content

Commit 962e44e

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 962e44e

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

src/cmd-kola

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

2020
basearch = cmdlib.get_basearch()
2121

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

102+
# Translation wrapper: convert old "kola testiso" to new "kola run iso.*"
103+
translate_testiso_args(kolaargs, subargs, unknown_args)
57104

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

0 commit comments

Comments
 (0)