Keep the tests off the machine's launchd - #2
Open
MaxFreedomPollard wants to merge 1 commit into
Open
Conversation
MaxFreedomPollard
force-pushed
the
claude/hopeful-tharp-bbc2ee
branch
from
August 1, 2026 02:04
2851de5 to
52fa259
Compare
A fake HOME moves the plist and nothing else. _gui_domain asks the real uid and LAUNCH_AGENT_LABEL is a module constant, so a macOS run of tests/test_status_bar_install.py deregistered the developer's own Compartment agent, left the real plist on disk unloaded, and started a second menu bar app from RunAtLoad. Confirmed by rerunning the old tests with a launchctl of our own first on PATH, which recorded bootout of gui/<real uid>/<real label> followed by a bootstrap of a plist in a temporary directory. menubar._launchctl now joins _systemctl and _schtasks in the autouse no_real_supervisors guard, so no test in any file reaches the real launchd by forgetting to stub it. The round trip keeps a recorder of its own and asserts the verbs: booted out before it is bootstrapped, confirmed by asking launchd rather than by the exit status of a verb, and deregistered before the plist is deleted. KeepAlive is asserted where it was not before, and the fixture also stops the login bundle being written into the real ~/Applications, since USER_APP_BUNDLE is bound at import, before HOME is faked. Coverage against the live launchd is kept as one test behind -m real_launchctl, deselected by default, which registers a per-pid label of its own running /usr/bin/true and boots it out in a finally.
MaxFreedomPollard
force-pushed
the
claude/hopeful-tharp-bbc2ee
branch
from
August 1, 2026 02:16
52fa259 to
997752d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The suite deregistered the real login agent. Two macOS tests redirected HOME and called
set_loginfor real. That moves the plist but not the launchd domain:_gui_domain()asks the real uid andLAUNCH_AGENT_LABELis a module constant, so running the tests booted the developer's own agent out of launchd, left~/Library/LaunchAgents/io.github.maxfreedompollard.compartment.menubar.pliston disk unloaded, and bootstrapped a job under the real label that RunAtLoad then started. They also wrote and codesigned a bundle in the real~/Applications, becauseUSER_APP_BUNDLEis bound at import while HOME is still real.menubar._launchctlnow joins_systemctland_schtasksin the autouseno_real_supervisorsguard, so no test in any file reaches the real launchd by forgetting to stub it. The round trip keeps a recorder of its own and the recorded verbs are the assertion:bootout, bootstrap, print, print, bootout, unload, each naming our own job and nothing else. The plist round trip still asserts, andRunAtLoadplusKeepAlive/SuccessfulExitare both checked where onlyRunAtLoadwas before.Coverage against the live launchd is kept as one test behind
pytest -m real_launchctl, deselected by default, which registers a per-pid label running/usr/bin/trueand boots it out in afinally. It writes its plist with a vault, so launchd reading the file back is a real check that theEnvironmentVariablesblock is well formed.Rebased onto main. This started as two commits; the second carried the start-at-login vault passthrough, which v4.4 shipped independently in
d6af2e9, with XML escaping this branch did not have.tests/test_menu_bar_persistence.pyalready covers every case those tests covered, so that commit is dropped and nothing from it is re-applied.Full suite green on macOS.