fix: relax start_new_session assertion for systemd scope path

The windows-compat change-detector checked for the literal string
'start_new_session=True', but the systemd scope isolation path
conditionally uses start_new_session=False (the scope creates its own
session/cgroup). Assert 'start_new_session=' instead — the value may
now be a variable.
This commit is contained in:
kshitij 2026-08-08 00:07:08 +05:30
parent b5c2116783
commit a8c50eb1d8
1 changed files with 10 additions and 4 deletions

View File

@ -51,17 +51,23 @@ class TestStartNewSession:
@pytest.mark.parametrize("relpath", GUARDED_FILES)
def test_uses_start_new_session(self, relpath):
"""Each guarded file must use start_new_session=True for process isolation."""
"""Each guarded file must use start_new_session instead of preexec_fn.
The value may be a variable (e.g. ``popen_start_new_session``) when
the spawn conditionally uses ``systemd-run --scope`` which creates its
own session/cgroup in that case ``start_new_session=False`` is
correct and a literal ``True`` would mask scope-creation failures.
"""
filepath = PROJECT_ROOT / relpath
if not filepath.exists():
pytest.skip(f"{relpath} not found")
source = filepath.read_text(encoding="utf-8")
# Files should use start_new_session=True, not preexec_fn
# Files should use start_new_session, not preexec_fn
assert "preexec_fn" not in source, (
f"{relpath} still uses preexec_fn; use start_new_session=True instead"
)
assert "start_new_session=True" in source, (
f"{relpath} missing start_new_session=True in Popen call"
assert "start_new_session=" in source, (
f"{relpath} missing start_new_session= in Popen call"
)