Skip to content

Commit 2de1081

Browse files
committed
more debugging and fix not_message handling
1 parent 32fd3ce commit 2de1081

File tree

2 files changed

+30
-22
lines changed

2 files changed

+30
-22
lines changed

ci/jobs/scripts/functional_tests_results.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,29 +96,31 @@ def test_is_known_fail(test_name, test_logs, known_broken_tests, test_options_st
9696
if not matching_rules:
9797
return False
9898

99-
def matches_field(field, log, is_regex):
100-
if field is None:
101-
return True
99+
def matches_substring(substring, log, is_regex):
102100
if log is None:
103101
return False
104102
if is_regex:
105-
return bool(field.search(log))
106-
return field in log
103+
return bool(substring.search(log))
104+
return substring in log
107105

108106
for rule_data in matching_rules:
109107
if rule_data.get("check_types") and not any(
110108
ct in test_options_string for ct in rule_data["check_types"]
111109
):
112-
print(f"Check types didn't match: {rule_data['check_types']} not in {test_options_string}")
110+
print(
111+
f"Check types didn't match: '{rule_data['check_types']}' not in '{test_options_string}'"
112+
)
113113
continue # check_types didn't match → skip rule
114114

115115
is_regex = rule_data.get("regex", False)
116-
if matches_field(rule_data.get("not_message"), test_logs, is_regex):
117-
print(f"Not message matched: {rule_data['not_message']}")
116+
not_message = rule_data.get("not_message")
117+
if not_message and matches_substring(not_message, test_logs, is_regex):
118+
print(f"Skip rule: Not message matched: '{rule_data['not_message']}'")
118119
continue # not_message matched → skip rule
119-
if not matches_field(rule_data.get("message"), test_logs, is_regex):
120-
print(f"Message didn't match: {rule_data['message']}")
121-
continue # message didn't match → skip rule
120+
message = rule_data.get("message")
121+
if message and not matches_substring(message, test_logs, is_regex):
122+
print(f"Skip rule: Message didn't match: '{rule_data['message']}'")
123+
continue
122124

123125
return rule_data["reason"]
124126

@@ -247,7 +249,10 @@ def _process_test_output(self):
247249

248250
if test[1] == "FAIL":
249251
broken_message = test_is_known_fail(
250-
test[0], test[3], known_broken_tests, test_options_string
252+
test[0],
253+
test_results_[-1].info,
254+
known_broken_tests,
255+
test_options_string,
251256
)
252257

253258
if broken_message:

ci/jobs/scripts/integration_tests_runner.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -524,27 +524,30 @@ def test_is_known_fail(test_name, test_logs, debug_log_file):
524524
if not matching_rules:
525525
return False
526526

527-
def matches_field(field, log, is_regex):
528-
if field is None:
529-
return True
527+
def matches_substring(substring, log, is_regex):
530528
if log is None:
531529
# Cannot match a message pattern if we have no logs
532530
return False
533531
if is_regex:
534-
return bool(field.search(log))
535-
return field in log
532+
return bool(substring.search(log))
533+
return substring in log
536534

537535
for rule_data in matching_rules:
538536
if rule_data.get("check_types") and not any(
539537
ct in context_name for ct in rule_data["check_types"]
540538
):
541-
continue # check_types didn't match → skip rule
539+
debug_log_file.write(f"Check types didn't match: '{rule_data['check_types']}' not in '{context_name}'\n")
540+
continue
542541

543542
is_regex = rule_data.get("regex", False)
544-
if matches_field(rule_data.get("not_message"), test_logs, is_regex):
545-
continue # not_message matched → skip rule
546-
if not matches_field(rule_data.get("message"), test_logs, is_regex):
547-
continue # message didn't match → skip rule
543+
not_message = rule_data.get("not_message")
544+
if not_message and matches_substring(not_message, test_logs, is_regex):
545+
debug_log_file.write(f"Skip rule: Not message matched: '{not_message}'\n")
546+
continue
547+
message = rule_data.get("message")
548+
if message and not matches_substring(message, test_logs, is_regex):
549+
debug_log_file.write(f"Skip rule: Message didn't match: '{message}'\n")
550+
continue
548551

549552
return rule_data["reason"]
550553

0 commit comments

Comments
 (0)