mirror of
https://github.com/morluto/rea.git
synced 2026-11-20 05:32:44 +00:00
test: own temporary directories through createTestTempDirectory in remaining tests/ (#12727)
* test: own temporary directories through createTestTempDirectory in remaining tests/ Give per-test directories in the remaining tests/ suites to createTestTempDirectory so onTestFinished removes them through removeTestWorkspace. Keep suite-scoped roots and child-process directories whose removal is the assertion. * test: drop empty cleanup callbacks and keep the capture skip reason visible Remove the no-op withVerifierCleanup steps left after directory removal moved to createTestTempDirectory. Put the native capture skip explanation in the Linux sample test name, because it.skipIf only tests truthiness. Co-authored-by: morluto <morluto@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: morluto <morluto@users.noreply.github.com>
This commit is contained in:
46 files changed
+1487
-1738
No files matched your search
@@ -9,6 +9,7 @@ import { createDarwinProcessRunTokenReader } from "../../src/process/DarwinProce
|
||||
import { createSystemProcessOwnershipHost } from "../../src/process/ProcessOwnershipObservation.js";
|
||||
import { startProcessSampler } from "../../src/process/capture/ProcessSampling.js";
|
||||
import { ProcessOwnershipInspectionCancelled } from "../../src/process/ProcessInspectionCancellation.js";
|
||||
import { createTestTempDirectory } from "../fixtures/temporaryDirectory.js";
|
||||
|
||||
const waitForFile = async (path: string, timeoutMs = 4_000): Promise<void> => {
|
||||
const deadline = Date.now() + timeoutMs;
|
||||
@@ -81,25 +82,21 @@ const createDelayedCommand = async (directory: string) => {
|
||||
const expectOwnedCommandToFinishOnAbort = async (
|
||||
run: (signal: AbortSignal, directory: string) => Promise<unknown>,
|
||||
): Promise<void> => {
|
||||
const directory = await mkdtemp(join(tmpdir(), "rea-process-command-"));
|
||||
const directory = await createTestTempDirectory("rea-process-command-");
|
||||
const command = await createDelayedCommand(directory);
|
||||
const controller = new AbortController();
|
||||
const reason = new Error("cancel owned process command");
|
||||
let pending: Promise<unknown> | undefined;
|
||||
onTestFinished(async () => {
|
||||
try {
|
||||
controller.abort(reason);
|
||||
await pending?.catch(() => {});
|
||||
if (
|
||||
await readFile(command.readyPath).then(
|
||||
() => true,
|
||||
() => false,
|
||||
)
|
||||
controller.abort(reason);
|
||||
await pending?.catch(() => {});
|
||||
if (
|
||||
await readFile(command.readyPath).then(
|
||||
() => true,
|
||||
() => false,
|
||||
)
|
||||
await waitForFile(command.donePath);
|
||||
} finally {
|
||||
await rm(directory, { recursive: true, force: true });
|
||||
}
|
||||
)
|
||||
await waitForFile(command.donePath);
|
||||
});
|
||||
|
||||
pending = run(controller.signal, directory);
|
||||
@@ -155,7 +152,7 @@ const processEntry = {
|
||||
it.skipIf(process.platform === "win32")(
|
||||
"waits for the owned ps command to exit when sampling stops",
|
||||
async () => {
|
||||
const directory = await mkdtemp(join(tmpdir(), "rea-process-sampler-"));
|
||||
const directory = await createTestTempDirectory("rea-process-sampler-");
|
||||
const readyPath = join(directory, "ready");
|
||||
const donePath = join(directory, "done");
|
||||
const psPath = join(directory, "ps");
|
||||
@@ -175,7 +172,6 @@ it.skipIf(process.platform === "win32")(
|
||||
await waitForFile(donePath);
|
||||
} finally {
|
||||
restoreProcessGlobals();
|
||||
await rm(directory, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -229,27 +225,23 @@ it
|
||||
const expectDarwinReaderCommandToFinishOnAbort = async (
|
||||
operation: "read" | "identities",
|
||||
): Promise<void> => {
|
||||
const directory = await mkdtemp(join(tmpdir(), `rea-darwin-${operation}-`));
|
||||
const directory = await createTestTempDirectory(`rea-darwin-${operation}-`);
|
||||
const command = await createDelayedCommand(directory);
|
||||
const reader = await createFakeDarwinReader(directory, command);
|
||||
const controller = new AbortController();
|
||||
const reason = new Error(`cancel ${operation}`);
|
||||
let pending: Promise<unknown> | undefined;
|
||||
onTestFinished(async () => {
|
||||
try {
|
||||
controller.abort(reason);
|
||||
await pending?.catch(() => {});
|
||||
if (
|
||||
await readFile(command.readyPath).then(
|
||||
() => true,
|
||||
() => false,
|
||||
)
|
||||
controller.abort(reason);
|
||||
await pending?.catch(() => {});
|
||||
if (
|
||||
await readFile(command.readyPath).then(
|
||||
() => true,
|
||||
() => false,
|
||||
)
|
||||
await waitForFile(command.donePath);
|
||||
await reader.close();
|
||||
} finally {
|
||||
await rm(directory, { recursive: true, force: true });
|
||||
}
|
||||
)
|
||||
await waitForFile(command.donePath);
|
||||
await reader.close();
|
||||
});
|
||||
|
||||
pending =
|
||||
|
||||
Reference in new issue
Block a user