mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-16 05:41:16 +01:00
feat(e2e): sync the neutral core from kfde 7de53180
This commit is contained in:
1 parent
8a8674ac9b
commit
632b6cc366
2 files changed
+37
-3
No files matched your search
@@ -44,22 +44,38 @@ def _settled(platform: Platform, title: str, count: int) -> None:
|
||||
platform.wait_for(lambda: platform.state().focused_title() == title, timeout=20)
|
||||
|
||||
|
||||
def run(platform: Platform, checks: Checks) -> None:
|
||||
def run(platform: Platform, checks: Checks, known_failures: dict[str, str] | None = None) -> None:
|
||||
"""Starts the daemon with each case's rules, opens its windows one after the other, and checks
|
||||
the order they are in.
|
||||
|
||||
`known_failures` maps the description of a case to why a port is known to fail it, whether
|
||||
its daemon does not start with the rules or puts the windows in another order. The case is
|
||||
then recorded as a known failure, and the others run on.
|
||||
|
||||
Nothing else may be open: the daemon takes up every window in view, and the order would
|
||||
count it. The windows of a case are closed before the next one. A window is opened only after
|
||||
the one before is managed and has the focus, because "after the one in focus" depends on it.
|
||||
"""
|
||||
known = known_failures or {}
|
||||
for description, rules, titles, want in CASES:
|
||||
platform.restart_with(_config(rules))
|
||||
reason = known.get(description)
|
||||
try:
|
||||
platform.restart_with(_config(rules))
|
||||
except Exception as error:
|
||||
if reason is None:
|
||||
raise
|
||||
checks.known_failure(description, False, f"{reason}; it did not start: {error}")
|
||||
continue
|
||||
clients: list[Client] = []
|
||||
for title in titles:
|
||||
clients.append(platform.spawn(title))
|
||||
_settled(platform, title, len(clients))
|
||||
got = _order(platform)
|
||||
checks.check(f"{description}: {', '.join(want)} ({got})", got == want)
|
||||
message = f"{description}: {', '.join(want)} ({got})"
|
||||
if reason is None:
|
||||
checks.check(message, got == want)
|
||||
else:
|
||||
checks.known_failure(message, got == want, reason)
|
||||
for client in clients:
|
||||
platform.close(client)
|
||||
platform.wait_for(lambda: platform.state().managed() == 0, timeout=20)
|
||||
@@ -300,3 +300,21 @@ def test_a_daemon_that_ignores_the_placement_rules_fails() -> None:
|
||||
checks = Checks()
|
||||
placement.run(platform, checks)
|
||||
assert checks.failed == len(placement.CASES) - 1, checks.failures
|
||||
|
||||
|
||||
def test_a_case_a_port_cannot_start_is_a_known_failure_and_the_rest_run() -> None:
|
||||
number = "by the number of the place, counted from 1"
|
||||
|
||||
class Refuses(FakePlatform):
|
||||
def restart_with(self, config: dict) -> None:
|
||||
workspace = config["monitors"][0]["workspaces"][0]
|
||||
if isinstance(workspace.get("initial_window_placement_rules"), int):
|
||||
raise AssertionError("exited at start")
|
||||
super().restart_with(config)
|
||||
|
||||
platform = Refuses()
|
||||
checks = Checks()
|
||||
placement.run(platform, checks, {number: "an integer is not accepted"})
|
||||
assert checks.failed == 0, checks.failures
|
||||
assert checks.passed == len(placement.CASES) - 1
|
||||
assert len(checks.known) == 1 and "exited at start" in checks.known[0]
|
||||
Reference in new issue
Block a user