mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-19 15:18:40 +01:00
feat(repo): scenario-status counts a scenario from its newest log
This commit is contained in:
1 parent
d2249f63dc
commit
3af590c300
3 files changed
+40
-13
No files matched your search
@@ -18,6 +18,9 @@ from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
# steps that are scenarios of their own, though their module has others: kfw runs them apart
|
||||
SCENARIOS = {"commands.unknown_monitor": "unknown_monitor"}
|
||||
|
||||
PREFIX = re.compile(r"^[\w.-]+> ")
|
||||
STEP = re.compile(r"^== \[(?P<scope>[\w-]+)\] (?P<name>[\w.]+)(?P<left_out>: left out by \w+)?\s*$")
|
||||
RESULT = re.compile(r"^ (?P<kind>ok |FAIL|skip|known failure) ")
|
||||
@@ -63,6 +66,14 @@ class Status:
|
||||
return table.setdefault(name, {}).setdefault(port, Counts())
|
||||
|
||||
|
||||
def merge(status: Status, newer: Status) -> None:
|
||||
"""Puts what `newer` has into `status`, instead of what it had of the same scenario: a scenario
|
||||
that two suites run (the shared `rules` runs in two) is counted once, from the later log."""
|
||||
for mine, theirs in ((status.shared, newer.shared), (status.extras, newer.extras)):
|
||||
for name, ports in theirs.items():
|
||||
mine.setdefault(name, {}).update(ports)
|
||||
|
||||
|
||||
def read_kde(status: Status, text: str) -> None:
|
||||
"""Adds the checks of a log of a run on KDE."""
|
||||
scenario: str | None = None
|
||||
@@ -73,8 +84,7 @@ def read_kde(status: Status, text: str) -> None:
|
||||
if step["left_out"]:
|
||||
scenario = None
|
||||
continue
|
||||
module = step["name"].split(".")[0]
|
||||
scenario = module
|
||||
scenario = SCENARIOS.get(step["name"], step["name"].split(".")[0])
|
||||
table = status.shared if step["scope"] == "shared" else status.extras
|
||||
continue
|
||||
if scenario is None:
|
||||
@@ -143,13 +153,7 @@ def table(status: Status) -> str:
|
||||
out = ["| scenario | kde | windows |", "|---|---|---|"]
|
||||
for name in sorted(status.shared):
|
||||
cells = [status.shared[name].get(port, Counts()) for port in ports]
|
||||
out.append(
|
||||
f"| `{name}` | "
|
||||
+ " | ".join(
|
||||
c.cell() if c.passed + c.failed + c.known + c.skipped else "not run" for c in cells
|
||||
)
|
||||
+ " |"
|
||||
)
|
||||
out.append(f"| `{name}` | " + " | ".join(_cell(c) for c in cells) + " |")
|
||||
out += ["", "Only on one port:", "", "| extra | kde | windows |", "|---|---|---|"]
|
||||
for name in sorted(status.extras):
|
||||
cells = [status.extras[name].get(port, Counts()) for port in ports]
|
||||
|
||||
@@ -23,7 +23,7 @@ def test_kde_counts_are_by_scenario_and_scope() -> None:
|
||||
tiling = found.shared["tiling"]["kde"]
|
||||
assert (tiling.passed, tiling.failed) == (1, 1)
|
||||
assert "focus" not in found.shared
|
||||
unknown = found.shared["commands"]["kde"]
|
||||
unknown = found.shared["unknown_monitor"]["kde"]
|
||||
assert (unknown.known, unknown.skipped) == (1, 1)
|
||||
assert found.extras["core_e2e"]["kde"].passed == 1
|
||||
|
||||
@@ -57,7 +57,7 @@ def test_the_table_has_a_row_for_each_scenario_and_a_dash_for_a_port_that_did_no
|
||||
found = status.Status()
|
||||
status.read_kde(found, KDE_LOG)
|
||||
out = status.table(found)
|
||||
assert "| `tiling` | FAIL 1 of 2 | not run |" in out or "| `tiling` | FAIL 1 of 2 | - |" in out
|
||||
assert "| `tiling` | FAIL 1 of 2 | - |" in out
|
||||
|
||||
|
||||
def test_the_region_between_the_markers_is_replaced() -> None:
|
||||
@@ -65,3 +65,23 @@ def test_the_region_between_the_markers_is_replaced() -> None:
|
||||
assert status.replace_region(document, "new\n") == (
|
||||
f"before\n{status.BEGIN}\nnew\n{status.END}\nafter\n"
|
||||
)
|
||||
|
||||
|
||||
def test_a_scenario_two_logs_have_is_counted_from_the_newer() -> None:
|
||||
older, newer, found = status.Status(), status.Status(), status.Status()
|
||||
status.read_kde(older, "== [shared] rules.run\n ok [shared] a\n ok [shared] b\n")
|
||||
status.read_kde(newer, "== [shared] rules.run\n ok [shared] a\n")
|
||||
status.merge(found, older)
|
||||
status.merge(found, newer)
|
||||
assert found.shared["rules"]["kde"].passed == 1
|
||||
|
||||
|
||||
def test_unknown_monitor_is_a_scenario_of_its_own() -> None:
|
||||
found = status.Status()
|
||||
status.read_kde(
|
||||
found,
|
||||
"== [shared] commands.sweep\n ok [shared] x\n"
|
||||
"== [shared] commands.unknown_monitor\n known failure [shared] y: why\n",
|
||||
)
|
||||
assert found.shared["commands"]["kde"].passed == 1
|
||||
assert found.shared["unknown_monitor"]["kde"].known == 1
|
||||
@@ -25,8 +25,11 @@ parser.add_argument("--update", type=Path, help="the document to put the table i
|
||||
args = parser.parse_args()
|
||||
|
||||
found = status.Status()
|
||||
for log in args.kde:
|
||||
status.read_kde(found, log.read_text(errors="replace"))
|
||||
# oldest first, so that a scenario two logs have is counted from the newer
|
||||
for log in sorted(args.kde, key=lambda path: path.stat().st_mtime):
|
||||
one = status.Status()
|
||||
status.read_kde(one, log.read_text(errors="replace"))
|
||||
status.merge(found, one)
|
||||
for directory in args.windows:
|
||||
status.read_windows(found, directory)
|
||||
text = status.table(found)
|
||||
|
||||
Reference in new issue
Block a user