Skip to content

test: cover daemon socket path and pid utilities - #2521

Merged
OrKoN merged 1 commit into
ChromeDevTools:mainfrom
ZayanKhan-12:chore/tests-daemon-utils
Aug 10, 2026
Merged

test: cover daemon socket path and pid utilities#2521
OrKoN merged 1 commit into
ChromeDevTools:mainfrom
ZayanKhan-12:chore/tests-daemon-utils

Conversation

@ZayanKhan-12

Copy link
Copy Markdown
Contributor

Why

src/daemon/utils.ts exports the functions that decide where the daemon socket and pid files live and whether a daemon is alive (getRuntimeHome, getSocketPath, getPidFilePath, getDaemonPid, isDaemonRunning), but tests/daemon/utils.test.ts only covered serializeArgs and assertValidSessionId. This adds direct unit coverage for the path-resolution and pid-lifecycle logic (243 added lines, tests only — no src/ changes).

Coverage

  • getRuntimeHome: XDG_RUNTIME_DIR respected / unset fallback, invalid session-id rejection
  • getSocketPath: unix socket path shape (with/without XDG_RUNTIME_DIR), Windows named-pipe format (platform-gated), invalid session-id rejection
  • getPidFilePath: daemon.pid inside the runtime home, invalid session-id rejection
  • getDaemonPid: missing file → null, whitespace tolerance, per-session scoping, empty/non-numeric contents → null, leading-integer parsing of malformed contents
  • isDaemonRunning: no pid file → false, live process (own pid) → true, dead process (exited child pid) → false

Env vars are saved/restored in hooks; pid files are written under mkdtemp temp 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

@google-cla

google-cla Bot commented Aug 8, 2026

Copy link
Copy Markdown

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
ZayanKhan-12 force-pushed the chore/tests-daemon-utils branch from f8d66dd to 3b6d384 Compare August 8, 2026 21:46
@OrKoN
OrKoN self-requested a review August 10, 2026 09:10
@OrKoN
OrKoN added this pull request to the merge queue Aug 10, 2026
Merged via the queue into ChromeDevTools:main with commit 073d4a3 Aug 10, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants