From ae9367fc8c466484144b7420f9f13832df464df4 Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Thu, 20 Aug 2026 12:30:20 -0500 Subject: [PATCH] test(s6): put the supervise-skeleton setgid assertion on the Linux lane MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_seed_supervise_skeleton_creates_expected_layout has been failing on every macOS checkout. The helper is correct — it chmods explicitly, so this isn't a umask problem. BSD drops S_ISGID from a directory chmod unless the caller is root or in the directory's group, so the same call that yields 03730 on Linux yields 01730 on macOS. s6 only ever runs on Linux, inside s6-overlay's stage2 as root with umask 0, so Linux is the host whose answer matters. Split the mode assertion into its own linux_only test rather than marking the whole case: the layout the test also covers (dirs present, supervise/ 0755, control is a 0660 FIFO) is host- independent and worth keeping on the machines developers actually run. --- tests/hermes_cli/test_service_manager.py | 31 ++++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/tests/hermes_cli/test_service_manager.py b/tests/hermes_cli/test_service_manager.py index 2b044de7c5..706611af90 100644 --- a/tests/hermes_cli/test_service_manager.py +++ b/tests/hermes_cli/test_service_manager.py @@ -193,7 +193,7 @@ def fake_subprocess_run(monkeypatch: pytest.MonkeyPatch): def test_seed_supervise_skeleton_creates_expected_layout(tmp_path) -> None: - """Verifies the dirs + FIFO + modes the helper lays down.""" + """Verifies the dirs + FIFO the helper lays down.""" import stat from hermes_cli.service_manager import _seed_supervise_skeleton @@ -206,9 +206,6 @@ def test_seed_supervise_skeleton_creates_expected_layout(tmp_path) -> None: # Top-level event/ — s6-svlisten1 event subscription dir. event = svc_dir / "event" assert event.is_dir(), "missing top-level event/" - assert stat.S_IMODE(event.stat().st_mode) == 0o3730, ( - f"event/ mode = {oct(event.stat().st_mode)}, want 03730" - ) # supervise/ dir. supervise = svc_dir / "supervise" @@ -218,7 +215,6 @@ def test_seed_supervise_skeleton_creates_expected_layout(tmp_path) -> None: # supervise/event/. supervise_event = supervise / "event" assert supervise_event.is_dir(), "missing supervise/event/" - assert stat.S_IMODE(supervise_event.stat().st_mode) == 0o3730 # supervise/control FIFO. control = supervise / "control" @@ -229,6 +225,31 @@ def test_seed_supervise_skeleton_creates_expected_layout(tmp_path) -> None: assert stat.S_IMODE(control.stat().st_mode) == 0o660 +@pytest.mark.linux_only +def test_seed_supervise_skeleton_sets_setgid_on_event_dirs(tmp_path) -> None: + """The event dirs carry setgid so s6-supervise's EEXIST path leaves them alone. + + Linux-only because the assertion is about what ``chmod`` does, and that + differs by kernel: BSD (macOS) silently drops ``S_ISGID`` from a directory + unless the caller is root or a member of the directory's group, so the same + correct helper produces 01730 there. s6 only ever runs on Linux — inside + s6-overlay's stage2 as root with umask 0 — so Linux is the host whose + answer matters. + """ + import stat + + from hermes_cli.service_manager import _seed_supervise_skeleton + + svc_dir = tmp_path / "gateway-foo" + svc_dir.mkdir() + + _seed_supervise_skeleton(svc_dir) + + for rel in ("event", "supervise/event"): + mode = stat.S_IMODE((svc_dir / rel).stat().st_mode) + assert mode == 0o3730, f"{rel}/ mode = {oct(mode)}, want 0o3730" + +