MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / withIsolatedExecutorDataDir

Function withIsolatedExecutorDataDir

apps/local/src/executor.test.ts:17–41  ·  view source on GitHub ↗
(body: () => Promise<void>)

Source from the content-addressed store, hash-verified

15} from "./executor";
16
17const withIsolatedExecutorDataDir = async (body: () => Promise<void>): Promise<void> => {
18 const previousDataDir = process.env.EXECUTOR_DATA_DIR;
19 const previousScopeDir = process.env.EXECUTOR_SCOPE_DIR;
20 const dataDir = mkdtempSync(join(tmpdir(), "executor-reload-race-"));
21
22 process.env.EXECUTOR_DATA_DIR = dataDir;
23 process.env.EXECUTOR_SCOPE_DIR = dataDir;
24
25 try {
26 await body();
27 } finally {
28 await disposeExecutor();
29 if (previousDataDir === undefined) {
30 delete process.env.EXECUTOR_DATA_DIR;
31 } else {
32 process.env.EXECUTOR_DATA_DIR = previousDataDir;
33 }
34 if (previousScopeDir === undefined) {
35 delete process.env.EXECUTOR_SCOPE_DIR;
36 } else {
37 process.env.EXECUTOR_SCOPE_DIR = previousScopeDir;
38 }
39 rmSync(dataDir, { recursive: true, force: true });
40 }
41};
42
43describe("reloadExecutor", () => {
44 it("waits for the previous owned database handle to release before reopening", async () => {

Callers 1

executor.test.tsFile · 0.85

Calls 1

disposeExecutorFunction · 0.90

Tested by

no test coverage detected