test: resolve the Windows temp directory to its long name (#9573)
Co-authored-by: Claude Code <[email protected]>
This commit is contained in:
1 parent
9af5139f59
commit
9fa54eeb4c
8 files changed
+69
-31
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import "vite-plus/test/config";
|
||||
import { defineConfig } from "vite-plus";
|
||||
|
||||
import { loadRepoEnv } from "../../scripts/lib/public-config.ts";
|
||||
@@ -87,5 +88,6 @@ export default defineConfig({
|
||||
// The Windows lane runs workspace suites concurrently; filesystem-heavy
|
||||
// desktop integration tests can exceed Vitest's 5 second default there.
|
||||
testTimeout: 15_000,
|
||||
setupFiles: ["../../packages/shared/src/testing/longTempDir.ts"],
|
||||
},
|
||||
});
|
||||
@@ -55,6 +55,8 @@ vi.mock("node:fs", async (importOriginal) => {
|
||||
};
|
||||
});
|
||||
|
||||
const windowsHost = HostProcessPlatform.defaultValue() === "win32";
|
||||
const nullDevice = windowsHost ? "\\\\.\\NUL" : "/dev/null";
|
||||
const TestEnvelopeSchema = Schema.Struct({ mode: Schema.String });
|
||||
const encodeTestEnvelopeSchema = Schema.encodeEffect(Schema.fromJsonString(TestEnvelopeSchema));
|
||||
|
||||
@@ -146,7 +148,7 @@ it.layer(NodeServices.layer)("readBootstrapEnvelope", (it) => {
|
||||
|
||||
it.effect("returns none when the fd is unavailable", () =>
|
||||
Effect.gen(function* () {
|
||||
const fd = NodeFS.openSync("/dev/null", "r");
|
||||
const fd = NodeFS.openSync(nullDevice, "r");
|
||||
NodeFS.closeSync(fd);
|
||||
|
||||
const payload = yield* readBootstrapEnvelope(TestEnvelopeSchema, fd, { timeoutMs: 100 });
|
||||
@@ -157,7 +159,7 @@ it.layer(NodeServices.layer)("readBootstrapEnvelope", (it) => {
|
||||
it.effect("preserves fd and cause when stat fails for a non-availability reason", () =>
|
||||
Effect.gen(function* () {
|
||||
const fd = yield* Effect.acquireRelease(
|
||||
Effect.sync(() => NodeFS.openSync("/dev/null", "r")),
|
||||
Effect.sync(() => NodeFS.openSync(nullDevice, "r")),
|
||||
(fd) => Effect.sync(() => NodeFS.closeSync(fd)),
|
||||
);
|
||||
|
||||
@@ -201,40 +203,43 @@ it.layer(NodeServices.layer)("readBootstrapEnvelope", (it) => {
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("returns none when the bootstrap read times out before any value arrives", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-bootstrap-" });
|
||||
const fifoPath = NodePath.join(tempDir, "bootstrap.pipe");
|
||||
// Needs a FIFO, which mkfifo creates; Windows has neither.
|
||||
it.effect.skipIf(windowsHost)(
|
||||
"returns none when the bootstrap read times out before any value arrives",
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-bootstrap-" });
|
||||
const fifoPath = NodePath.join(tempDir, "bootstrap.pipe");
|
||||
|
||||
yield* Effect.sync(() => NodeChildProcess.execFileSync("mkfifo", [fifoPath]));
|
||||
yield* Effect.sync(() => NodeChildProcess.execFileSync("mkfifo", [fifoPath]));
|
||||
|
||||
const _writer = yield* Effect.acquireRelease(
|
||||
Effect.sync(() =>
|
||||
NodeChildProcess.spawn("sh", ["-c", 'exec 3>"$1"; sleep 60', "sh", fifoPath], {
|
||||
stdio: ["ignore", "ignore", "ignore"],
|
||||
}),
|
||||
),
|
||||
(writer) =>
|
||||
Effect.sync(() => {
|
||||
writer.kill("SIGKILL");
|
||||
}),
|
||||
);
|
||||
const _writer = yield* Effect.acquireRelease(
|
||||
Effect.sync(() =>
|
||||
NodeChildProcess.spawn("sh", ["-c", 'exec 3>"$1"; sleep 60', "sh", fifoPath], {
|
||||
stdio: ["ignore", "ignore", "ignore"],
|
||||
}),
|
||||
),
|
||||
(writer) =>
|
||||
Effect.sync(() => {
|
||||
writer.kill("SIGKILL");
|
||||
}),
|
||||
);
|
||||
|
||||
const fd = yield* Effect.acquireRelease(
|
||||
Effect.sync(() => NodeFS.openSync(fifoPath, "r")),
|
||||
(fd) => Effect.sync(() => NodeFS.closeSync(fd)),
|
||||
);
|
||||
const fd = yield* Effect.acquireRelease(
|
||||
Effect.sync(() => NodeFS.openSync(fifoPath, "r")),
|
||||
(fd) => Effect.sync(() => NodeFS.closeSync(fd)),
|
||||
);
|
||||
|
||||
const fiber = yield* readBootstrapEnvelope(TestEnvelopeSchema, fd, {
|
||||
timeoutMs: 100,
|
||||
}).pipe(Effect.forkScoped);
|
||||
const fiber = yield* readBootstrapEnvelope(TestEnvelopeSchema, fd, {
|
||||
timeoutMs: 100,
|
||||
}).pipe(Effect.forkScoped);
|
||||
|
||||
yield* Effect.yieldNow;
|
||||
yield* TestClock.adjust(Duration.millis(100));
|
||||
yield* Effect.yieldNow;
|
||||
yield* TestClock.adjust(Duration.millis(100));
|
||||
|
||||
const payload = yield* Fiber.join(fiber);
|
||||
assertNone(payload);
|
||||
}).pipe(Effect.provide(TestClock.layer())),
|
||||
const payload = yield* Fiber.join(fiber);
|
||||
assertNone(payload);
|
||||
}).pipe(Effect.provide(TestClock.layer())),
|
||||
);
|
||||
});
|
||||
@@ -78,6 +78,7 @@ export default mergeConfig(
|
||||
// The server suite exercises sqlite, git, temp worktrees, and orchestration
|
||||
// runtimes heavily. Running files in parallel introduces load-sensitive flakes.
|
||||
fileParallelism: false,
|
||||
// Appended to the root setup, which mergeConfig concatenates.
|
||||
setupFiles: ["./src/testUtils/gitConfig.setup.ts"],
|
||||
// Server integration tests exercise sqlite, git, and orchestration together.
|
||||
// Under package-wide runs they can exceed the default budget on loaded CI hosts.
|
||||
|
||||
@@ -80,6 +80,7 @@ const unitTestProject = {
|
||||
// run, those async tests can exceed Vitest's default 5s budget.
|
||||
hookTimeout: 15_000,
|
||||
testTimeout: 15_000,
|
||||
setupFiles: ["../../packages/shared/src/testing/longTempDir.ts"],
|
||||
},
|
||||
} satisfies TestProjectInlineConfiguration;
|
||||
|
||||
|
||||
@@ -5,5 +5,6 @@ export default defineConfig({
|
||||
test: {
|
||||
environment: "node",
|
||||
include: ["src/**/*.test.ts"],
|
||||
setupFiles: ["../shared/src/testing/longTempDir.ts"],
|
||||
},
|
||||
});
|
||||
@@ -223,6 +223,10 @@
|
||||
"types": "./src/hostProcess.ts",
|
||||
"import": "./src/hostProcess.ts"
|
||||
},
|
||||
"./testing/longTempDir": {
|
||||
"types": "./src/testing/longTempDir.ts",
|
||||
"import": "./src/testing/longTempDir.ts"
|
||||
},
|
||||
"./testing/symlinks": {
|
||||
"types": "./src/testing/symlinks.ts",
|
||||
"import": "./src/testing/symlinks.ts"
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// @effect-diagnostics nodeBuiltinImport:off - runs once at test setup, outside any Effect runtime.
|
||||
import * as NodeFS from "node:fs";
|
||||
import * as NodeOS from "node:os";
|
||||
import { HostProcessPlatform } from "../hostProcess.ts";
|
||||
|
||||
// GitHub's Windows runners hand out the temp directory by its 8.3 short name
|
||||
// (C:\Users\RUNNER~1\...). Anything that canonicalises a path, such as git or
|
||||
// realpath, reports the long form, so equality checks between a temp path and
|
||||
// its canonical form fail. Node reads TEMP/TMP on every os.tmpdir() call, so
|
||||
// pointing them at the long form fixes every temp directory the suite makes.
|
||||
if (HostProcessPlatform.defaultValue() === "win32") {
|
||||
try {
|
||||
const longForm = NodeFS.realpathSync.native(NodeOS.tmpdir());
|
||||
process.env.TEMP = longForm;
|
||||
process.env.TMP = longForm;
|
||||
} catch {
|
||||
// Leave the host's value alone if it cannot be resolved.
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,11 @@ export default defineConfig({
|
||||
],
|
||||
hookTimeout: 60_000,
|
||||
testTimeout: 60_000,
|
||||
setupFiles: [
|
||||
NodeURL.fileURLToPath(
|
||||
new URL("./packages/shared/src/testing/longTempDir.ts", import.meta.url),
|
||||
),
|
||||
],
|
||||
},
|
||||
staged: {
|
||||
// Formatter only for now — no lint or typecheck on commit.
|
||||
|
||||
Reference in new issue
Block a user