test(core): add IPv6 netstat test for findPidByPort + mark _resetShellCache as @internal
- Add test case for IPv6 LISTENING entries ([::]:3000) in Windows netstat output - Add @internal JSDoc to _resetShellCache to clarify it is test-only Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
ae1a6e4fc5
commit
2c12b1eef6
|
|
@ -272,6 +272,21 @@ describe("findPidByPort", () => {
|
|||
expect(pid).toBeNull();
|
||||
});
|
||||
|
||||
it("finds PID from IPv6 LISTENING line on Windows", async () => {
|
||||
setPlatform("win32");
|
||||
// netstat -ano includes IPv6 entries like [::]:3000 when server binds to all interfaces
|
||||
const netstatOutput = [
|
||||
" Proto Local Address Foreign Address State PID",
|
||||
" TCP [::]:3000 [::]:0 LISTENING 55",
|
||||
].join("\n");
|
||||
resolveExecFile(netstatOutput);
|
||||
|
||||
const mod = await import("../platform.js");
|
||||
const pid = await mod.findPidByPort(3000);
|
||||
|
||||
expect(pid).toBe("55");
|
||||
});
|
||||
|
||||
it("returns null when no LISTENING line matches on Windows", async () => {
|
||||
setPlatform("win32");
|
||||
resolveExecFile(" TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 99\n");
|
||||
|
|
|
|||
|
|
@ -63,7 +63,9 @@ export function getShell(): ShellInfo {
|
|||
return cachedShell;
|
||||
}
|
||||
|
||||
/** Reset cached shell (for testing) */
|
||||
/** Reset cached shell (for testing)
|
||||
* @internal
|
||||
*/
|
||||
export function _resetShellCache(): void {
|
||||
cachedShell = null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue