History

Merge remote-tracking branch 'origin/codex/batch10-daemon-state-boundaries' into codex/effect-lint-integration

Rhys Sullivan committed 6 months ago

Commit af548c52 parents 9ff4452 8fe08581 file · +19 −17Browse files

Unified · Split

tests/daemon-state.test.ts+19−17
@@ -24,7 +24,7 @@ const fileSystemError = (method: string, cause: unknown) => · 23 unmodified lines
2424 _tag: "Unknown",
2525 module: "FileSystem",
2626 method,
27− description: cause instanceof Error ? cause.message : String(cause),
27+ description: "FileSystem operation failed",
2828 cause,
2929 });
3030
@@ -54,22 +54,24 @@ const fileSystemLayer = FileSystem.layerNoop({ · 23 unmodified lines
5454 const daemonStateLayer = Layer.merge(fileSystemLayer, Path.layer);
5555
5656 const withDaemonDataDir = <A, E>(effect: Effect.Effect<A, E, FileSystem.FileSystem | Path.Path>) =>
57− Effect.gen(function* () {
58− const prev = process.env.EXECUTOR_DATA_DIR;
59− const dir = mkdtempSync(join(tmpdir(), "executor-daemon-state-test-"));
60− process.env.EXECUTOR_DATA_DIR = dir;
61−
62− try {
63− return yield* effect;
64− } finally {
65− if (prev === undefined) {
66− delete process.env.EXECUTOR_DATA_DIR;
67− } else {
68− process.env.EXECUTOR_DATA_DIR = prev;
69− }
70− rmSync(dir, { recursive: true, force: true });
71− }
72− }).pipe(Effect.provide(daemonStateLayer));
57+ Effect.acquireUseRelease(
58+ Effect.sync(() => {
59+ const prev = process.env.EXECUTOR_DATA_DIR;
60+ const dir = mkdtempSync(join(tmpdir(), "executor-daemon-state-test-"));
61+ process.env.EXECUTOR_DATA_DIR = dir;
62+ return { dir, prev };
63+ }),
64+ () => effect,
65+ ({ dir, prev }) =>
66+ Effect.sync(() => {
67+ if (prev === undefined) {
68+ delete process.env.EXECUTOR_DATA_DIR;
69+ } else {
70+ process.env.EXECUTOR_DATA_DIR = prev;
71+ }
72+ rmSync(dir, { recursive: true, force: true });
73+ }),
74+ ).pipe(Effect.provide(daemonStateLayer));
7375
7476 describe("daemon state", () => {
7577 it("normalizes local host aliases", () => {