From 09c59849f36c17942375ea42f565ed58681c759a Mon Sep 17 00:00:00 2001 From: ZelinWang Date: Tue, 27 Jun 2023 14:14:10 +0800 Subject: [PATCH] [CICD] Fix cmdcov (#396) * update * update --- HISTORY.rst | 8 ++++++-- azdev/__init__.py | 2 +- azdev/operations/linter/linter.py | 9 --------- azdev/operations/regex.py | 8 +++++--- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 25be300a..88a44948 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -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 ++++++ diff --git a/azdev/__init__.py b/azdev/__init__.py index 74cde6ab..fc526619 100644 --- a/azdev/__init__.py +++ b/azdev/__init__.py @@ -4,4 +4,4 @@ # license information. # ----------------------------------------------------------------------------- -__VERSION__ = '0.1.51' +__VERSION__ = '0.1.52' diff --git a/azdev/operations/linter/linter.py b/azdev/operations/linter/linter.py index 46a98248..8438d924 100644 --- a/azdev/operations/linter/linter.py +++ b/azdev/operations/linter/linter.py @@ -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.') @@ -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 diff --git a/azdev/operations/regex.py b/azdev/operations/regex.py index 61cbbf95..f062bf3b 100644 --- a/azdev/operations/regex.py +++ b/azdev/operations/regex.py @@ -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('_', '-')] @@ -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