Skip to content

Commit

Permalink
fix: device name doesn't always appear in the last line
Browse files Browse the repository at this point in the history
  • Loading branch information
tomli380576 committed Dec 4, 2024
1 parent bfedca0 commit a684219
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions checkbox-support/checkbox_support/parsers/v4l2_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ def parse_v4l2_compliance(
lines.append(clean_line)

pattern = (
r"Total for (.*): (.*), Succeeded: (.*), Failed: (.*), Warnings: (.*)"
r"Total(?: for (.*))?: (.*), "
r"Succeeded: (.*), Failed: (.*), Warnings: (.*)"
)
match_output = re.match(pattern, lines[-1])

Expand All @@ -160,7 +161,7 @@ def parse_v4l2_compliance(
)

summary = {
"device_name": match_output.group(1),
"device_name": match_output.group(1), # could be null
"total": int(match_output.group(2)),
"succeeded": int(match_output.group(3)),
"failed": int(match_output.group(4)),
Expand All @@ -174,6 +175,15 @@ def parse_v4l2_compliance(
} # type: dict[str, list[str]]

for line in lines:
if summary["device_name"] is None and line.startswith(
"Compliance test for"
):
name_line_pattern = r"Compliance test for (*.)"
name_match = re.match(name_line_pattern, line)

Check warning on line 182 in checkbox-support/checkbox_support/parsers/v4l2_compliance.py

View check run for this annotation

Codecov / codecov/patch

checkbox-support/checkbox_support/parsers/v4l2_compliance.py#L181-L182

Added lines #L181 - L182 were not covered by tests
if name_match is not None:
summary["device_name"] = name_match.group(1)
continue

Check warning on line 185 in checkbox-support/checkbox_support/parsers/v4l2_compliance.py

View check run for this annotation

Codecov / codecov/patch

checkbox-support/checkbox_support/parsers/v4l2_compliance.py#L184-L185

Added lines #L184 - L185 were not covered by tests

if line.endswith(": OK"):
result = "succeeded"
elif line.endswith(": OK (Not Supported)"):
Expand Down

0 comments on commit a684219

Please sign in to comment.