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.
This commit is contained in:
parent
2ad93da755
commit
68f61b2e2f
1 changed files with 2 additions and 0 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue