mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-30 16:39:33 +01:00
test(tmux): let the live pane die on its signal, so Linux CI never reads /proc
The live-pane close test mocked process.kill to always succeed, so the pane never exited and the kill path's wait polled isProcessRunning(). On Linux that reads /proc/<pid>/stat, which this file mocks to return undefined, and the test threw "Cannot read properties of undefined (reading 'lastIndexOf')". macOS skips that read, so it passed locally. The mock now models a pane that exits on its first real signal, after which kill(pid, 0) throws ESRCH. Reproduced the CI error locally by forcing the Linux branch; it passes with this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ccf502b7a8
commit
891f3a19e9
1 file changed
+13
-1
@@ -1386,7 +1386,19 @@ describe('TmuxManager (unit)', () => {
|
||||
if (callback) setImmediate(() => callback(null, { stdout, stderr: '' }, ''));
|
||||
return { on: vi.fn(), kill: vi.fn(), pid: 12345 };
|
||||
}) as unknown as typeof exec);
|
||||
const kill = vi.spyOn(process, 'kill').mockImplementation(() => true);
|
||||
// The pane's process exits on its first real signal, as a live CLI does.
|
||||
// Afterwards the liveness probe (`kill(pid, 0)`) throws, so the kill path
|
||||
// stops waiting before it reads /proc, which this file mocks (Linux CI).
|
||||
let paneAlive = true;
|
||||
const kill = vi.spyOn(process, 'kill').mockImplementation(((pid: number, signal?: string | number) => {
|
||||
if (Math.abs(pid) !== 4343) return true;
|
||||
if (signal === 0) {
|
||||
if (paneAlive) return true;
|
||||
throw Object.assign(new Error('kill ESRCH'), { code: 'ESRCH' });
|
||||
}
|
||||
paneAlive = false;
|
||||
return true;
|
||||
}) as typeof process.kill);
|
||||
const NonTestTmuxManager = await importWithTmuxCommandsEnabled();
|
||||
const nonTestManager = new NonTestTmuxManager();
|
||||
nonTestManager.registerSession({
|
||||
|
||||
Reference in new issue
Block a user