Skip to content

Commit

Permalink
[CICD] Fix cmdcov (#396)
Browse files Browse the repository at this point in the history
* update

* update
  • Loading branch information
wangzelin007 authored Jun 27, 2023
1 parent 261d436 commit 09c5984
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
8 changes: 6 additions & 2 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
Release History
===============
0.1.52
++++++
* Fix cmdcov issue(#396): Fix the regex which to get the command group

0.1.51
++++++
* Fix cmdcov issue(#391)
* Fix cmdcov issue(#391): Add violation message to cmdcov linter rule and fix related issues

0.1.50
++++++
* Fix cmdcov issue(#385)
* Fix cmdcov issue(#385): Add cmdcov to package data

0.1.49
++++++
Expand Down
2 changes: 1 addition & 1 deletion azdev/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# license information.
# -----------------------------------------------------------------------------

__VERSION__ = '0.1.51'
__VERSION__ = '0.1.52'
9 changes: 0 additions & 9 deletions azdev/operations/linter/linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,9 @@ def _run_command_test_coverage(commands, all_tested_command):
for command in commands:
for code in all_tested_command:
if command in code:
_logger.debug("Find '%s' test case in '%s'", command, code)
break
else:
violations.append(f'Missing command test coverage: `{command}`')
_logger.error("Can not find '%s' test case", command)
_logger.error("Please add some scenario tests for the new command")
_logger.error("Or add the command with missing_command_test_coverage rule in linter_exclusions.yml")
exec_state = False
if violations:
violations.insert(0, 'Failed.')
Expand All @@ -342,15 +338,10 @@ def _run_parameter_test_coverage(parameters, all_tested_command):
for opt in opt_list:
for code in all_tested_command:
if command in code and opt in code:
_logger.debug("Find '%s' test case in '%s'", command + ' ' + opt, code)
flag = True
break
else:
violations.append(f'Missing parameter test coverage: `{command} {opt}`')
_logger.error("Can not find '%s' test case", command + ' ' + opt)
_logger.error("Please add some scenario tests for the new parameter")
_logger.error(
"Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml")
exec_state = False
if flag:
break
Expand Down
8 changes: 5 additions & 3 deletions azdev/operations/regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ def search_argument(line):
if 'options_list' in ref[0]:
# Match ` options_list=xxx, or options_list=xxx)`
sub_pattern = r'options_list=\[(.*?)\]'
params = re.findall(sub_pattern, ref[0])[0].replace('\'', '').replace('"', '').replace(' ', '').split(',')
ref2 = re.findall(sub_pattern, ref[0])
if ref2:
params = ref2[0].replace('\'', '').replace('"', '').replace(' ', '').split(',')
else:
# if options_list not exist, generate by parameter name
params = ['--' + param_name.replace('_', '-')]
Expand All @@ -140,8 +142,8 @@ def search_command_group(row_num, lines, command):
cmd = ''
while row_num > 0:
row_num -= 1
# Match `with self.command_group('local-context',`
sub_pattern = r'with self.command_group\(\'(.*?)\','
# Match `with self.command_group('local-context',` and `with self.command_group('xxx')`
sub_pattern = r'with self.command_group\(\'(.*?)\',?'
group = re.findall(sub_pattern, lines[row_num])
if group:
cmd = group[0] + ' ' + command
Expand Down

0 comments on commit 09c5984

Please sign in to comment.