test: continue vitest threads migration

This commit is contained in:
Peter Steinberger
2026-03-24 02:00:22 +00:00
parent d41b92fff2
commit 2833b27f52
110 changed files with 3163 additions and 994 deletions

View File

@@ -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();