Skip to content

Commit f666808

Browse files
committed
test(server): both git spawn sites start Windows reads without a console
1 parent 49325e5 commit f666808

2 files changed

Lines changed: 88 additions & 0 deletions

File tree

‎apps/server/src/processRunner.test.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ type ChildProcessCommand = {
1919
readonly args: ReadonlyArray<string>;
2020
readonly options: {
2121
readonly shell?: boolean | string;
22+
readonly detached?: boolean;
23+
readonly windowsHide?: boolean;
2224
};
2325
};
2426

@@ -165,6 +167,40 @@ describe("runProcess", () => {
165167
);
166168
});
167169

170+
it.effect("starts Git for Windows reads without a console", () => {
171+
const spawned: Array<{
172+
readonly args: ReadonlyArray<string>;
173+
readonly detached: boolean | undefined;
174+
readonly windowsHide: boolean | undefined;
175+
}> = [];
176+
const spawner = makeSpawner((command) =>
177+
Effect.sync(() => {
178+
spawned.push({
179+
args: command.args,
180+
detached: command.options.detached,
181+
windowsHide: command.options.windowsHide,
182+
});
183+
return makeHandle({});
184+
}),
185+
);
186+
187+
return Effect.gen(function* () {
188+
yield* runWith(spawner)({ command: "git", args: ["rev-parse", "HEAD"] });
189+
yield* runWith(spawner)({ command: "git", args: ["status", "--porcelain"] });
190+
191+
expect(spawned).toStrictEqual([
192+
{ args: ["rev-parse", "HEAD"], detached: true, windowsHide: true },
193+
{ args: ["status", "--porcelain"], detached: undefined, windowsHide: undefined },
194+
]);
195+
}).pipe(
196+
Effect.provideService(HostProcess.Platform, "win32"),
197+
Effect.provideService(
198+
SpawnExecutableResolution,
199+
() => "C:\\Program Files\\Git\\mingw64\\bin\\git.exe",
200+
),
201+
);
202+
});
203+
168204
it.effect("preserves resolved spawn context and cause", () =>
169205
Effect.gen(function* () {
170206
const cause = PlatformError.systemError({

‎apps/server/src/vcs/GitVcsDriverCore.test.ts‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import * as NodeFS from "node:fs";
33
import * as NodeServices from "@effect/platform-node/NodeServices";
44
import * as HostProcess from "@t3tools/shared/HostProcess";
5+
import { SpawnExecutableResolution } from "@t3tools/shared/shell";
56
import { assert, it, describe } from "@effect/vitest";
67
import * as Deferred from "effect/Deferred";
78
import * as Effect from "effect/Effect";
@@ -339,6 +340,57 @@ it.effect("uses stable diagnostics for every parsed non-repository command", ()
339340
}).pipe(Effect.provide(layer));
340341
});
341342

343+
it.effect("starts Git for Windows reads without a console", () => {
344+
const commands: Array<{
345+
readonly args: ReadonlyArray<string>;
346+
readonly detached: boolean | undefined;
347+
readonly windowsHide: boolean | undefined;
348+
}> = [];
349+
const spawner = ChildProcessSpawner.make((command) =>
350+
Effect.sync(() => {
351+
if (!ChildProcess.isStandardCommand(command)) {
352+
return assert.fail("expected a standard Git command");
353+
}
354+
commands.push({
355+
args: command.args,
356+
detached: command.options.detached,
357+
windowsHide: command.options.windowsHide,
358+
});
359+
return makeNonRepositoryHandle();
360+
}),
361+
);
362+
const layer = GitVcsDriver.layer.pipe(
363+
Layer.provide(layerServerConfig),
364+
Layer.provideMerge(
365+
Layer.mergeAll(
366+
NodeServices.layer,
367+
Layer.succeed(ChildProcessSpawner.ChildProcessSpawner, spawner),
368+
Layer.succeed(HostProcess.Platform, "win32"),
369+
),
370+
),
371+
);
372+
373+
return Effect.gen(function* () {
374+
const driver = yield* GitVcsDriver.GitVcsDriver;
375+
yield* driver.statusDetailsLocal("/repo");
376+
377+
assert.deepStrictEqual(commands, [
378+
{ args: ["rev-parse", "--git-path", "index"], detached: true, windowsHide: true },
379+
{
380+
args: ["status", "--porcelain=2", "--branch"],
381+
detached: undefined,
382+
windowsHide: undefined,
383+
},
384+
]);
385+
}).pipe(
386+
Effect.provide(layer),
387+
Effect.provideService(
388+
SpawnExecutableResolution,
389+
() => "C:\\Program Files\\Git\\mingw64\\bin\\git.exe",
390+
),
391+
);
392+
});
393+
342394
it.effect("invalidates origin remote cache when a driver mutation adds origin", () =>
343395
Effect.gen(function* () {
344396
const driver = yield* GitVcsDriver.GitVcsDriver;

0 commit comments

Comments
 (0)