test: cover daemon socket path and pid utilities - #2521
Merged
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
ZayanKhan-12
force-pushed
the
chore/tests-daemon-utils
branch
from
August 8, 2026 21:46
f8d66dd to
3b6d384
Compare
OrKoN
self-requested a review
August 10, 2026 09:10
OrKoN
approved these changes
Aug 10, 2026
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.
Why
src/daemon/utils.tsexports the functions that decide where the daemon socket and pid files live and whether a daemon is alive (getRuntimeHome,getSocketPath,getPidFilePath,getDaemonPid,isDaemonRunning), buttests/daemon/utils.test.tsonly coveredserializeArgsandassertValidSessionId. This adds direct unit coverage for the path-resolution and pid-lifecycle logic (243 added lines, tests only — nosrc/changes).Coverage
getRuntimeHome: XDG_RUNTIME_DIR respected / unset fallback, invalid session-id rejectiongetSocketPath: unix socket path shape (with/without XDG_RUNTIME_DIR), Windows named-pipe format (platform-gated), invalid session-id rejectiongetPidFilePath: daemon.pid inside the runtime home, invalid session-id rejectiongetDaemonPid: missing file → null, whitespace tolerance, per-session scoping, empty/non-numeric contents → null, leading-integer parsing of malformed contentsisDaemonRunning: no pid file → false, live process (own pid) → true, dead process (exited child pid) → falseEnv vars are saved/restored in hooks; pid files are written under
mkdtemptemp dirs, nothing touches real daemon state.Testing
node scripts/test.js tests/daemon/utils.test.ts→ pass (exit 0)npm run test:no-build→ full suite pass (exit 0)npm run check-format→ eslint + prettier clean