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
1414 import * as WorkspaceEntries from "./WorkspaceEntries.ts";
1515 import * as WorkspaceFileSystem from "./WorkspaceFileSystem.ts";
1616 import * as WorkspacePaths from "./WorkspacePaths.ts";
17+import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
1718 import { symlinksSupported } from "@t3tools/shared/testing/symlinks";
1819
1920 const ProjectLayer = WorkspaceFileSystem.layer.pipe(
@@ -100,28 +101,31 @@ it.layer(TestLayer, { excludeTestServices: true })("WorkspaceFileSystemLive", (i · 80 unmodified lines
100101 }),
101102 );
102103
103− it.effect("rejects a FIFO without blocking on open", () =>
104− Effect.gen(function* () {
105− const workspaceFileSystem = yield* WorkspaceFileSystem.WorkspaceFileSystem;
106− const path = yield* Path.Path;
107− const cwd = yield* makeTempDir;
108− const outsideDir = yield* makeTempDir;
109− const fifoPath = path.join(outsideDir, "pipe");
110− yield* Effect.promise(
111− () =>
112− new Promise<void>((resolve, reject) =>
113− NodeChildProcess.execFile("mkfifo", [fifoPath], (error) =>
114− error ? reject(error) : resolve(),
104+ // Needs mkfifo; Windows has no FIFOs to reject.
105+ it.effect.skipIf(HostProcessPlatform.defaultValue() === "win32")(
106+ "rejects a FIFO without blocking on open",
107+ () =>
108+ Effect.gen(function* () {
109+ const workspaceFileSystem = yield* WorkspaceFileSystem.WorkspaceFileSystem;
110+ const path = yield* Path.Path;
111+ const cwd = yield* makeTempDir;
112+ const outsideDir = yield* makeTempDir;
113+ const fifoPath = path.join(outsideDir, "pipe");
114+ yield* Effect.promise(
115+ () =>
116+ new Promise<void>((resolve, reject) =>
117+ NodeChildProcess.execFile("mkfifo", [fifoPath], (error) =>
118+ error ? reject(error) : resolve(),
119+ ),
115120 ),
116− ),
117− );
121+ );
118122
119− const error = yield* workspaceFileSystem
120− .readFile({ cwd, relativePath: fifoPath })
121− .pipe(Effect.flip);
123+ const error = yield* workspaceFileSystem
124+ .readFile({ cwd, relativePath: fifoPath })
125+ .pipe(Effect.flip);
122126
123− expect(error).toBeInstanceOf(WorkspaceFileSystem.WorkspacePathNotFileError);
124− }),
127+ expect(error).toBeInstanceOf(WorkspaceFileSystem.WorkspacePathNotFileError);
128+ }),
125129 );
126130
127131 it.effect("rejects reads outside the workspace root", () =>