test(coding-agent/core): consolidated python executor session lifecycle tests

- Added a lifecycle test case verifying executePython retries execution with a fresh kernel when the prior session kernel dies during run.
- Removed the now-redundant python-executor-session.test.ts file that defined session lifecycle tests.
This commit is contained in:
can1357
2026-06-14 19:04:18 +02:00
parent 73f2dbc3b5
commit c362976ac5
2 changed files with 20 additions and 104 deletions
@@ -100,6 +100,26 @@ describe("executePython lifecycle", () => {
expect(kernelNext.execute).toHaveBeenCalledTimes(1);
});
it("restarts after an execution failure when kernel is dead", async () => {
const kernel = new FakeKernel(OK_RESULT);
kernel.execute.mockImplementation(async () => {
kernel.alive = false;
throw new Error("kernel crashed");
});
const kernelNext = new FakeKernel(OK_RESULT);
vi.spyOn(pythonKernel, "checkPythonKernelAvailability").mockResolvedValue({ ok: true });
const startSpy = vi
.spyOn(pythonKernel.PythonKernel, "start")
.mockResolvedValueOnce(kernel as unknown as pythonKernel.PythonKernel)
.mockResolvedValueOnce(kernelNext as unknown as pythonKernel.PythonKernel);
await executePython("1 + 1", { kernelMode: "session", sessionId: "crash-session", cwd: getProjectDir() });
expect(startSpy).toHaveBeenCalledTimes(2);
expect(kernel.execute).toHaveBeenCalledTimes(1);
expect(kernelNext.execute).toHaveBeenCalledTimes(1);
});
it("restarts dead retained sessions even when shutdown confirmation is missing", async () => {
const kernel = new FakeKernel(OK_RESULT);
const kernelNext = new FakeKernel(OK_RESULT);