Skip to content
TypeScript

test: use an empty config file instead of the null device for git fixtures on Windows (#30772)

Pyseph95c0fbd4b5cb
diff --git a/apps/server/src/vcs/GitVcsDriverCore.test.ts b/apps/server/src/vcs/GitVcsDriverCore.test.ts
index 532a6db2b9e..39427404093 100644
--- a/apps/server/src/vcs/GitVcsDriverCore.test.ts
+++ b/apps/server/src/vcs/GitVcsDriverCore.test.ts
@@ -1,6 +1,6 @@
// @effect-diagnostics nodeBuiltinImport:off - realpathSync.native resolves Windows 8.3 short names, which the Effect realPath does not.
import * as NodeFS from "node:fs";
-import * as NodeOS from "node:os";
+import * as NodePath from "node:path";
import * as NodeURL from "node:url";
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
import * as NodeServices from "@effect/platform-node/NodeServices";
@@ -2172,7 +2172,11 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
const upstream = yield* makeTmpDir();
yield* initRepoWithCommit(upstream);
const driver = yield* GitVcsDriver.GitVcsDriver;
- const emptyTree = yield* git(upstream, ["hash-object", "-t", "tree", NodeOS.devNull]);
+ // Git for Windows rejects the null device as a path, so use an empty file.
+ const emptyDir = yield* makeTmpDir("git-vcs-driver-empty-");
+ yield* writeTextFile(emptyDir, "empty", "");
+ const emptyFile = NodePath.join(emptyDir, "empty");
+ const emptyTree = yield* git(upstream, ["hash-object", "-t", "tree", emptyFile]);
const root = yield* git(upstream, ["rev-parse", "HEAD"]);
const rootSource = (yield* driver.getReviewDiffPreview({ cwd: upstream, commitSha: root }))
.sources[0]!;
@@ -2192,7 +2196,7 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
const sha = yield* git(upstream, ["rev-parse", "HEAD"]);
const cwd = yield* makeTmpDir();
yield* git(upstream, ["clone", "--depth=1", NodeURL.pathToFileURL(upstream).href, cwd], {
- GIT_CONFIG_GLOBAL: NodeOS.devNull,
+ GIT_CONFIG_GLOBAL: emptyFile,
GIT_CONFIG_NOSYSTEM: "1",
});
assert.equal(yield* git(cwd, ["rev-parse", "--is-shallow-repository"]), "true");
diff --git a/scripts/check-changed.test.ts b/scripts/check-changed.test.ts
index 17c9b2b4bb2..ccc7b6e1c84 100644
--- a/scripts/check-changed.test.ts
+++ b/scripts/check-changed.test.ts
@@ -6,7 +6,7 @@ import * as NodePath from "node:path";
import { expect } from "vite-plus/test";
import * as NodeServices from "@effect/platform-node/NodeServices";
import * as Option from "effect/Option";
-import { assert, describe, it } from "@effect/vitest";
+import { afterAll, assert, describe, it } from "@effect/vitest";
import * as Clock from "effect/Clock";
import * as Effect from "effect/Effect";
import * as Fiber from "effect/Fiber";
@@ -208,14 +208,21 @@ describe("check:changed", () => {
// Hooks export GIT_DIR and GIT_INDEX_FILE, and user config or the default
// ~/.config/git/ignore can ignore or sign fixture files.
+// Git for Windows rejects the null device as a config path, so use an empty file.
+const emptyConfigDir = NodeFS.mkdtempSync(
+ NodePath.join(NodeOS.tmpdir(), "t3-check-changed-config-"),
+);
+const emptyConfig = NodePath.join(emptyConfigDir, "empty.gitconfig");
+NodeFS.writeFileSync(emptyConfig, "");
+afterAll(() => NodeFS.rmSync(emptyConfigDir, { recursive: true, force: true }));
const fixtureConfig = {
- "core.excludesFile": NodeOS.devNull,
+ "core.excludesFile": emptyConfig,
"user.name": "Fixture",
"user.email": "[email protected]",
};
const env = {
...Object.fromEntries(Object.entries(process.env).filter(([name]) => !name.startsWith("GIT_"))),
- GIT_CONFIG_GLOBAL: NodeOS.devNull,
+ GIT_CONFIG_GLOBAL: emptyConfig,
GIT_CONFIG_NOSYSTEM: "1",
GIT_CONFIG_COUNT: String(Object.keys(fixtureConfig).length),
...Object.fromEntries(