mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 03:11:10 +00:00
test: continue vitest threads migration
This commit is contained in:
@@ -1,12 +1,4 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
addSession,
|
||||
getFinishedSession,
|
||||
getSession,
|
||||
resetProcessRegistryForTests,
|
||||
} from "./bash-process-registry.js";
|
||||
import { createProcessSessionFixture } from "./bash-process-registry.test-helpers.js";
|
||||
import { createProcessTool } from "./bash-tools.process.js";
|
||||
|
||||
const { supervisorMock } = vi.hoisted(() => ({
|
||||
supervisorMock: {
|
||||
@@ -30,6 +22,21 @@ vi.mock("../process/kill-tree.js", () => ({
|
||||
killProcessTree: (...args: unknown[]) => killProcessTreeMock(...args),
|
||||
}));
|
||||
|
||||
let addSession: typeof import("./bash-process-registry.js").addSession;
|
||||
let getFinishedSession: typeof import("./bash-process-registry.js").getFinishedSession;
|
||||
let getSession: typeof import("./bash-process-registry.js").getSession;
|
||||
let resetProcessRegistryForTests: typeof import("./bash-process-registry.js").resetProcessRegistryForTests;
|
||||
let createProcessSessionFixture: typeof import("./bash-process-registry.test-helpers.js").createProcessSessionFixture;
|
||||
let createProcessTool: typeof import("./bash-tools.process.js").createProcessTool;
|
||||
|
||||
async function loadFreshProcessToolModulesForTest() {
|
||||
vi.resetModules();
|
||||
({ addSession, getFinishedSession, getSession, resetProcessRegistryForTests } =
|
||||
await import("./bash-process-registry.js"));
|
||||
({ createProcessSessionFixture } = await import("./bash-process-registry.test-helpers.js"));
|
||||
({ createProcessTool } = await import("./bash-tools.process.js"));
|
||||
}
|
||||
|
||||
function createBackgroundSession(id: string, pid?: number) {
|
||||
return createProcessSessionFixture({
|
||||
id,
|
||||
@@ -40,7 +47,8 @@ function createBackgroundSession(id: string, pid?: number) {
|
||||
}
|
||||
|
||||
describe("process tool supervisor cancellation", () => {
|
||||
beforeEach(() => {
|
||||
beforeEach(async () => {
|
||||
await loadFreshProcessToolModulesForTest();
|
||||
supervisorMock.spawn.mockClear();
|
||||
supervisorMock.cancel.mockClear();
|
||||
supervisorMock.cancelScope.mockClear();
|
||||
|
||||
Reference in New Issue
Block a user