From 35f4ababe1594ea41dc4ed44ac70f9b4a65621ce Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Tue, 1 Sep 2026 02:25:55 -0700 Subject: [PATCH] test: the managed-dashboard restart now continues the serve scan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_user_scope_restart_never_falls_back_to_system_or_sudo asserted the short-circuit (#92145 barrier 5) that this change deliberately removes. Its real invariant — user scope never falls back to system scope or sudo — is kept; the scan-continues side is now asserted instead of forbidden. --- tests/hermes_cli/test_update_stale_dashboard.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/hermes_cli/test_update_stale_dashboard.py b/tests/hermes_cli/test_update_stale_dashboard.py index cf3a199dc4..9177b53745 100644 --- a/tests/hermes_cli/test_update_stale_dashboard.py +++ b/tests/hermes_cli/test_update_stale_dashboard.py @@ -231,7 +231,15 @@ class TestKillStaleDashboardPosix: def test_user_scope_restart_never_falls_back_to_system_or_sudo(self, capsys): - """A user unit is discovered and restarted through ``systemctl --user``.""" + """A user unit is discovered and restarted through ``systemctl --user``. + + Since #92145 the managed restart no longer ends the pass — the scan + for OTHER stale serve/dashboard backends continues (with the restarted + unit recorded in ``already_restarted_units``), so the scan being + reached is now part of the contract rather than a violation of it. + The invariant this test pins is unchanged: nothing here may touch the + system scope or sudo. + """ calls: list[list[str]] = [] def fake_run(args, *a, **kw): @@ -247,7 +255,7 @@ class TestKillStaleDashboardPosix: raise AssertionError(f"unexpected subprocess.run call: {args}") with patch("subprocess.run", side_effect=fake_run), \ - patch("hermes_cli.main._find_stale_dashboard_pids", return_value=[12345]) as find_pids, \ + patch("hermes_cli.main._find_stale_dashboard_pids", return_value=[]) as find_pids, \ patch("os.kill") as kill: _kill_stale_dashboard_processes(restart_managed=True) @@ -258,7 +266,9 @@ class TestKillStaleDashboardPosix: ["systemctl", "--user", "restart", "hermes-dashboard.service"], ] assert all(call[:1] != ["sudo"] and call[:2] != ["systemctl"] for call in calls) - find_pids.assert_not_called() + # The pass keeps scanning for serve backends the dashboard unit does + # not own (#92145) — but with nothing stale, nothing is killed. + find_pids.assert_called_once() kill.assert_not_called() assert "✓ restarted hermes-dashboard.service" in capsys.readouterr().out