Skip to content

Commit

Permalink
Fix unreachable code in plugins-test
Browse files Browse the repository at this point in the history
Some codelines in update-mode were unreachable.
This change fixes it and slightly refactors the update-mode logic.

Change-Id: I0c58ebc434d86b8d30beb24fc10f0a90c143cdf4
  • Loading branch information
MatteoStifano committed Oct 23, 2023
1 parent 93e59e7 commit 31f5261
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions tests/plugins_integration/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,6 @@ def _verify_check_result(
if result_data and canon_data == result_data:
return True, ""

if mode == CheckModes.UPDATE:
logger.info("[%s] Canon updated!", check_id)
return True, ""

with open(
json_canon_file_path := str(output_dir / f"{safe_name}.canon.json"),
mode="w",
Expand All @@ -272,10 +268,11 @@ def _verify_check_result(
check=False,
).stdout

if len(canon_data) != len(result_data):
logger.error("[%s] Invalid field count! Data mismatch:\n%s", check_id, diff)
else:
logger.error("[%s] Data mismatch:\n%s", check_id, diff)
if mode == CheckModes.DEFAULT:
if len(canon_data) != len(result_data):
logger.error("[%s] Invalid field count! Data mismatch:\n%s", check_id, diff)
else:
logger.error("[%s] Data mismatch:\n%s", check_id, diff)

return False, diff

Expand Down Expand Up @@ -323,16 +320,17 @@ def process_check_output(
output_dir,
config.mode,
)
if config.mode == CheckModes.UPDATE and diff:
check_canons[check_id] = check_results[check_id]
logger.info("[%s] Canon updated!", check_id)
passed = True
continue
if check_success:
if passed is None:
passed = True
continue
if config.mode == CheckModes.UPDATE:
check_canons[check_id] = check_results[check_id]
logger.info("[%s] Canon updated!", check_id)
passed = True
else:
passed = False

passed = False
diffs[check_id] = diff

if diffs:
Expand Down

0 comments on commit 31f5261

Please sign in to comment.