Merge 0c93e8099f into c9e3bb7ca4
This commit is contained in:
commit
39fa04b83a
|
|
@ -0,0 +1,40 @@
|
|||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
runChildProcess: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("../utils.js", async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import("../utils.js")>()),
|
||||
runChildProcess: mocks.runChildProcess,
|
||||
}));
|
||||
|
||||
import { execute } from "./execute.js";
|
||||
|
||||
describe("process adapter execution", () => {
|
||||
it("fails when a child is terminated by a signal with no exit code", async () => {
|
||||
mocks.runChildProcess.mockResolvedValueOnce({
|
||||
exitCode: null,
|
||||
signal: "SIGTERM",
|
||||
timedOut: false,
|
||||
stdout: "",
|
||||
stderr: "",
|
||||
});
|
||||
|
||||
const result = await execute({
|
||||
runId: "signal-test",
|
||||
agent: { id: "agent", companyId: "company" },
|
||||
config: { command: process.execPath },
|
||||
onLog: async () => {},
|
||||
onMeta: async () => {},
|
||||
} as any);
|
||||
|
||||
expect(result).toMatchObject({
|
||||
exitCode: null,
|
||||
signal: "SIGTERM",
|
||||
timedOut: false,
|
||||
});
|
||||
expect(result.errorMessage).toContain("SIGTERM");
|
||||
expect(result.resultJson).toEqual({ stdout: "", stderr: "" });
|
||||
});
|
||||
});
|
||||
|
|
@ -80,6 +80,19 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
|
|||
};
|
||||
}
|
||||
|
||||
if (proc.signal) {
|
||||
return {
|
||||
exitCode: proc.exitCode,
|
||||
signal: proc.signal,
|
||||
timedOut: false,
|
||||
errorMessage: `Process terminated by signal ${proc.signal}`,
|
||||
resultJson: {
|
||||
stdout: proc.stdout,
|
||||
stderr: proc.stderr,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if ((proc.exitCode ?? 0) !== 0) {
|
||||
return {
|
||||
exitCode: proc.exitCode,
|
||||
|
|
|
|||
Loading…
Reference in New Issue