Skip to content

Commit d600510

Browse files
committed
FEAT: Add --vt-keep-at-variants-in-shortnames option to preserve @default variants in test names
Add new command-line option --vt-keep-at-variants-in-shortnames to control whether @-prefixed variants (like @default) are included in short test names when using --vt-short-names-when-config. Changes: - virttest/cartesian_config.py: Add keep_at_variants_in_shortnames parameter to Parser constructor and modify shortname generation logic - avocado_vt/plugins/vt.py: Add new CLI option --vt-keep-at-variants-in-shortnames - avocado_vt/plugins/vt_init.py: Register new setting for keep_at_variants_in_shortnames - avocado_vt/options.py: Pass new parameter to cartesian parser instantiation Usage: avocado run xxxxx --vt-config myconfig.cfg --vt-short-names-when-config --vt-keep-at-variants-in-shortnames Without the flag: test.eim_off.q35 (excludes @default) With the flag: test.eim_off.default.q35 (includes @default) Assisted-By: Claude Sonnet 4 <noreply@anthropic.com> Signed-off-by: Houqi (Nick) Zuo <hzuo@redhat.com>
1 parent a3cfa5a commit d600510

4 files changed

Lines changed: 33 additions & 3 deletions

File tree

avocado_vt/options.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,11 @@ def _process_options(self):
545545
% (vt_type_setting, vt_type, " ".join(SUPPORTED_TEST_TYPES))
546546
)
547547

548-
self.cartesian_parser = cartesian_config.Parser(debug=False)
548+
keep_at_variants = get_opt(self.config, "vt.keep_at_variants_in_shortnames", False)
549+
self.cartesian_parser = cartesian_config.Parser(
550+
debug=False,
551+
keep_at_variants_in_shortnames=keep_at_variants
552+
)
549553

550554
if vt_config:
551555
cfg = os.path.abspath(vt_config)

avocado_vt/plugins/vt.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,19 @@ def add_basic_vt_options(parser):
6868
help=help_msg,
6969
)
7070

71+
help_msg = (
72+
"Keep @-prefixed variants (like @default) in short names. "
73+
"Only works when --vt-short-names-when-config is also enabled."
74+
)
75+
add_option(
76+
parser,
77+
dest="vt.keep_at_variants_in_shortnames",
78+
arg="--vt-keep-at-variants-in-shortnames",
79+
action="store_true",
80+
default=False,
81+
help=help_msg,
82+
)
83+
7184
help_msg = "Choose test type (%s). Default: %%(default)s" % ", ".join(
7285
SUPPORTED_TEST_TYPES
7386
)

avocado_vt/plugins/vt_init.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ def initialize(self):
5959
help_msg=help_msg,
6060
)
6161

62+
help_msg = (
63+
"Keep @-prefixed variants (like @default) in short names. "
64+
"Only works when short_names_when_config is also enabled."
65+
)
66+
settings.register_option(
67+
section,
68+
key="keep_at_variants_in_shortnames",
69+
key_type=bool,
70+
default=False,
71+
help_msg=help_msg,
72+
)
73+
6274
help_msg = "Choose test type (%s). Default: %%(default)s" % ", ".join(
6375
SUPPORTED_TEST_TYPES
6476
)

virttest/cartesian_config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,11 +1480,12 @@ def parse_filter(lexer, tokens):
14801480
class Parser(object):
14811481
# pylint: disable=W0102
14821482

1483-
def __init__(self, filename=None, defaults=False, expand_defaults=[], debug=False):
1483+
def __init__(self, filename=None, defaults=False, expand_defaults=[], debug=False, keep_at_variants_in_shortnames=False):
14841484
self.node = Node()
14851485
self.debug = debug
14861486
self.defaults = defaults
14871487
self.expand_defaults = [LIdentifier(x) for x in expand_defaults]
1488+
self.keep_at_variants_in_shortnames = keep_at_variants_in_shortnames
14881489

14891490
self.filename = filename
14901491
if self.filename:
@@ -1787,7 +1788,7 @@ def _parse(self, lexer, node=None, prev_indent=-1):
17871788
node3.default = True
17881789
already_default = True
17891790

1790-
node3.append_to_shortname = not is_default
1791+
node3.append_to_shortname = not is_default or self.keep_at_variants_in_shortnames
17911792

17921793
op = LUpdateFileMap()
17931794
op.set_operands(

0 commit comments

Comments
 (0)