-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tmt t lint should also try to cover adjust rules #1334
base: main
Are you sure you want to change the base?
Conversation
0f2ddc9
to
f233b2a
Compare
1cbc0ca
to
336b382
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't work unfortunately because 'when' (and 'because') are not known to the lint:
/tests/run/worktree
pass test script must be defined
pass directory path must be absolute
pass directory path must exist
fail unknown attribute 'when' is used
fail unknown attribute 'when' is used
It would be also good to add test to show that lint does its job and points about invalid attribute in adjust rules.
tmt/base.py
Outdated
if prop_adjust is not None: | ||
if isinstance(prop_adjust, dict): | ||
node_keys.extend(prop_adjust.keys()) | ||
elif isinstance(prop_adjust, list) or isinstance(prop_adjust, tuple): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second argument can be tuple of allowed types so you can use
elif isinstance(prop_adjust, (list, tuple)):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, thanks!
@lukaszachy, Thanks for your quick review. I'm thinking how to get all keywords supported by 'adjust'. Currently (Pdb) ll
289 def lint_keys(self, additional_keys):
290 """ Return list of invalid keys used, empty when all good """
291 known_keys = additional_keys + self._keys
292 node_keys = list(self.node.get().keys())
293 prop_adjust = self.node.get('adjust')
294 if prop_adjust is not None:
295 B-> if isinstance(prop_adjust, dict):
296 node_keys.extend(prop_adjust.keys())
......
302 return [key for key in node_keys if key not in known_keys]
(Pdb) p additional_keys
['extra-nitrate', 'extra-hardware', 'extra-pepa', 'extra-summary', 'extra-task', 'relevancy', 'coverage', 'adjust']
(Pdb) up
> /home/huanli/.virtualenvs/tmt/lib/python3.10/site-packages/tmt/base.py(572)lint()
-> invalid_keys = self.lint_keys(
(Pdb) l
.......
572 -> invalid_keys = self.lint_keys(
573 EXTRA_TEST_KEYS + OBSOLETED_TEST_KEYS + ['adjust'])
574 if invalid_keys:
......
(Pdb) p EXTRA_TEST_KEYS + OBSOLETED_TEST_KEYS + ['adjust']
['extra-nitrate', 'extra-hardware', 'extra-pepa', 'extra-summary', 'extra-task', 'relevancy', 'coverage', 'adjust'] Any suggestion?
OK, will have a try. |
336b382
to
149ddbc
Compare
@idorax Hm, it gets more complicated. I think check needs to be done in two steps as "adjust" and "when+because" are mutually exclusive. So lint :
Maybe time to add constants with |
149ddbc
to
0544ee7
Compare
Any plans with this one, @idorax? |
Currently I don't have bandwidth to work on this issue, let me work on it in 1.32, thanks! |
c5020ec
to
2653fb5
Compare
Some test to play with:
There should be no "fail" for /valid. |
2653fb5
to
3bcda1f
Compare
Thanks, @lukaszachy! Will have a try :-) |
3bcda1f
to
8de53fc
Compare
Signed-off-by: Vector Li <[email protected]>
8de53fc
to
7f9ec8c
Compare
Fixes #898. If
adjust
has some L2 keys, we should pick up those keys when invokingCore.lint_keys()
.