-
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 try to cover adjust rules as well #898
Comments
Also when you forget the "when" keyword, lint crashes and you get a long traceback. |
For test: foo
adjust:
- when: distro == fedora
enable: false
(Pdb) b tmt/base.py:291
Breakpoint 1 at /home/huanli/.virtualenvs/tmt/lib/python3.10/site-packages/tmt/base.py:291
(Pdb) c
/a
pass test script must be defined
pass directory path must be absolute
pass directory path must exist
warn summary is very useful for quick inspection
> /home/huanli/.virtualenvs/tmt/lib/python3.10/site-packages/tmt/base.py(291)lint_keys()
-> known_keys = additional_keys + self._keys
(Pdb) ll
289 def lint_keys(self, additional_keys):
290 """ Return list of invalid keys used, empty when all good """
291 B-> known_keys = additional_keys + self._keys
292 return [key for key in self.node.get().keys() if key not in known_keys]
(Pdb) pp additional_keys, self._keys
(['extra-nitrate',
'extra-hardware',
'extra-pepa',
'extra-summary',
'extra-task',
'relevancy',
'coverage',
'adjust'],
['summary',
'description',
'contact',
'component',
'test',
'path',
'framework',
'manual',
'require',
'recommend',
'environment',
'duration',
'enabled',
'order',
'result',
'tag',
'tier',
'link'])
(Pdb) pp self.node.get()
{'adjust': [{'enable': False, 'when': 'distro == fedora'}], 'test': 'foo'}
(Pdb) pp self.node.get().keys()
dict_keys(['adjust', 'test'])
# ^^^^^^^^^^^^^^^ It doesn't include key 'enable' and 'when' !!! Hence, it looks we should get the L2 keys at tmt/base.py#L292. |
To get L2 keys in property (Pdb) p self.node.get()
{'adjust': [{'when': 'distro == fedora', 'enable': False}], 'test': 'foo'}
(Pdb) prop_adjust = self.node.get('adjust')
(Pdb) adjust_keys = [key for item in prop_adjust for key in item.keys()]
(Pdb) pp adjust_keys
['when', 'enable'] |
Fix [issue#898](teemtee#898) Signed-off-by: Vector Li <[email protected]>
Fixes teemtee#898 Signed-off-by: Vector Li <[email protected]>
Here is a brief summary after discussing with TMT developers.
|
I made typo in adjust rules, tmt tests lint didn't show any error: (enable vs enabled)
Since adjust keys are defined (when, because and every tmt attribute for its object) we should be able to lint for unknown/typos
The text was updated successfully, but these errors were encountered: