History

test(server): make Windows path and async fixtures deterministic (#9576)

Julius Marminge committed 2 months ago

Commit b123cbb1 parent 5f4c7169 files · +125 −75Browse files

Showing the changes to apps/server/src/workspace/WorkspaceFileSystem.test.ts (1 of 9 files). Show all

Unified · Split

apps/server/src/workspace/WorkspaceFileSystem.test.ts+23−19
@@ -14,6 +14,7 @@ import * as VcsProcess from "../vcs/VcsProcess.ts"; · 13 unmodified lines
14import * as WorkspaceEntries from "./WorkspaceEntries.ts";14import * as WorkspaceEntries from "./WorkspaceEntries.ts";
15import * as WorkspaceFileSystem from "./WorkspaceFileSystem.ts";15import * as WorkspaceFileSystem from "./WorkspaceFileSystem.ts";
16import * as WorkspacePaths from "./WorkspacePaths.ts";16import * as WorkspacePaths from "./WorkspacePaths.ts";
17import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
17import { symlinksSupported } from "@t3tools/shared/testing/symlinks";18import { symlinksSupported } from "@t3tools/shared/testing/symlinks";
18 19
19const ProjectLayer = WorkspaceFileSystem.layer.pipe(20const ProjectLayer = WorkspaceFileSystem.layer.pipe(
@@ -100,28 +101,31 @@ it.layer(TestLayer, { excludeTestServices: true })("WorkspaceFileSystemLive", (i · 80 unmodified lines
100 }),101 }),
101 );102 );
102 103
103 it.effect("rejects a FIFO without blocking on open", () =>104 // Needs mkfifo; Windows has no FIFOs to reject.
104 Effect.gen(function* () {105 it.effect.skipIf(HostProcessPlatform.defaultValue() === "win32")(
105 const workspaceFileSystem = yield* WorkspaceFileSystem.WorkspaceFileSystem;106 "rejects a FIFO without blocking on open",
106 const path = yield* Path.Path;107 () =>
107 const cwd = yield* makeTempDir;108 Effect.gen(function* () {
108 const outsideDir = yield* makeTempDir;109 const workspaceFileSystem = yield* WorkspaceFileSystem.WorkspaceFileSystem;
109 const fifoPath = path.join(outsideDir, "pipe");110 const path = yield* Path.Path;
110 yield* Effect.promise(111 const cwd = yield* makeTempDir;
111 () =>112 const outsideDir = yield* makeTempDir;
112 new Promise<void>((resolve, reject) =>113 const fifoPath = path.join(outsideDir, "pipe");
113 NodeChildProcess.execFile("mkfifo", [fifoPath], (error) =>114 yield* Effect.promise(
114 error ? reject(error) : resolve(),115 () =>
116 new Promise<void>((resolve, reject) =>
117 NodeChildProcess.execFile("mkfifo", [fifoPath], (error) =>
118 error ? reject(error) : resolve(),
119 ),
115 ),120 ),
116 ),121 );
117 );
118 122
119 const error = yield* workspaceFileSystem123 const error = yield* workspaceFileSystem
120 .readFile({ cwd, relativePath: fifoPath })124 .readFile({ cwd, relativePath: fifoPath })
121 .pipe(Effect.flip);125 .pipe(Effect.flip);
122 126
123 expect(error).toBeInstanceOf(WorkspaceFileSystem.WorkspacePathNotFileError);127 expect(error).toBeInstanceOf(WorkspaceFileSystem.WorkspacePathNotFileError);
124 }),128 }),
125 );129 );
126 130
127 it.effect("rejects reads outside the workspace root", () =>131 it.effect("rejects reads outside the workspace root", () =>