From 68f61b2e2fbde2f378e2030d025d094e99ef6536 Mon Sep 17 00:00:00 2001 From: Chinesezjc Date: Tue, 18 Aug 2026 16:58:59 +0800 Subject: [PATCH] test(code-runtime-python): exempt the two single-platform teardown arms from coverage The PID-reuse guard has two arms no single OS can execute: the non-Linux early return in readProcessStart (the Linux coverage lane always takes the read path) and the refusal arm, which needs a real pid recycled into a new group leader between spawn and teardown -- no test can schedule that. The coverage lane reported 99.53% statements / 99.14% branches on src/index.ts for exactly these two. Both carry a v8 ignore naming what cannot be reached and why, the convention this file and subprocess-local already use for platform defenses. The reader itself stays covered by the process-identity test rather than being exempted wholesale. --- packages/code-runtime/code-runtime-python/src/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/code-runtime/code-runtime-python/src/index.ts b/packages/code-runtime/code-runtime-python/src/index.ts index 604cc420b9..7f0bac4dd0 100644 --- a/packages/code-runtime/code-runtime-python/src/index.ts +++ b/packages/code-runtime/code-runtime-python/src/index.ts @@ -335,6 +335,7 @@ const GROUP_REAP_POLL_MS = 50 * @returns its start time, or undefined when unavailable. */ export function readProcessStart(pid: number): string | undefined { + /* v8 ignore next -- one arm per platform: the Linux coverage lane always takes the read path, and Darwin always this one. */ if (process.platform !== 'linux') return undefined try { const stat = readFileSync(`/proc/${String(pid)}/stat`, 'utf8') @@ -1427,6 +1428,7 @@ export class PythonCodeRuntime extends CodeRuntime { // falls through, which is also the behavior on platforms with no // `/proc` to read. const nowStarted = readProcessStart(child.pid) + /* v8 ignore next -- the refusal arm needs a real pid recycled into a new group leader between spawn and teardown, which no test can schedule; `readProcessStart` is covered directly instead. */ if (leaderStarted !== undefined && nowStarted !== undefined && nowStarted !== leaderStarted) return process.kill(-child.pid, sig) } catch {