mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-17 06:17:09 +00:00
fix(test): pin real child_process passthrough refs
- bind real spawn/spawnSync/execSync before module mocking - avoid potential rebinding recursion or mock passthrough drift in CI - keeps non-Claude process execution untouched during test mocks
This commit is contained in:
@@ -13,6 +13,9 @@ const originalPlatform = process.platform;
|
||||
let baselineSigintListeners: Array<(...args: unknown[]) => void> = [];
|
||||
let baselineSigtermListeners: Array<(...args: unknown[]) => void> = [];
|
||||
let baselineSighupListeners: Array<(...args: unknown[]) => void> = [];
|
||||
const realSpawn = childProcess.spawn.bind(childProcess);
|
||||
const realSpawnSync = childProcess.spawnSync.bind(childProcess);
|
||||
const realExecSync = childProcess.execSync.bind(childProcess);
|
||||
|
||||
function createMockChild(): EventEmitter & {
|
||||
stdout: EventEmitter;
|
||||
@@ -65,11 +68,7 @@ function registerChildProcessMock(): void {
|
||||
| undefined;
|
||||
|
||||
if (!shouldMockCommand(command)) {
|
||||
return childProcess.spawn(
|
||||
command,
|
||||
args,
|
||||
options as Parameters<typeof childProcess.spawn>[2]
|
||||
);
|
||||
return realSpawn(command, args, options as Parameters<typeof childProcess.spawn>[2]);
|
||||
}
|
||||
|
||||
spawnCalls.push({ command, args, options });
|
||||
@@ -86,14 +85,10 @@ function registerChildProcessMock(): void {
|
||||
| Record<string, unknown>
|
||||
| undefined;
|
||||
|
||||
return childProcess.spawnSync(
|
||||
command,
|
||||
args,
|
||||
options as Parameters<typeof childProcess.spawnSync>[2]
|
||||
);
|
||||
return realSpawnSync(command, args, options as Parameters<typeof childProcess.spawnSync>[2]);
|
||||
},
|
||||
execSync: (...execArgs: unknown[]) =>
|
||||
childProcess.execSync(
|
||||
realExecSync(
|
||||
execArgs[0] as Parameters<typeof childProcess.execSync>[0],
|
||||
execArgs[1] as Parameters<typeof childProcess.execSync>[1]
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user