Open History to see the last commit
1import { describe, expect, it } from "vitest";
2
3import { isWindowsCommandNotFound, runProcess } from "./processRunner.ts";
4
5describe("runProcess", () => {
6 it("fails when output exceeds max buffer in default mode", async () => {
7 await expect(
8 runProcess("node", ["-e", "process.stdout.write('x'.repeat(2048))"], { maxBufferBytes: 128 }),
9 ).rejects.toThrow("exceeded stdout buffer limit");
10 });
11
12 it("truncates output when outputMode is truncate", async () => {
13 const result = await runProcess("node", ["-e", "process.stdout.write('x'.repeat(2048))"], {
14 maxBufferBytes: 128,
15 outputMode: "truncate",
16 });
17
18 expect(result.code).toBe(0);
19 expect(result.stdout.length).toBeLessThanOrEqual(128);
20 expect(result.stdoutTruncated).toBe(true);
21 expect(result.stderrTruncated).toBe(false);
22 });
23});
24
25describe("isWindowsCommandNotFound", () => {
26 it("matches the localized German cmd.exe error text", () => {
27 const originalPlatform = process.platform;
28 Object.defineProperty(process, "platform", { value: "win32", configurable: true });
29
30 try {
31 expect(
32 isWindowsCommandNotFound(
33 1,
34 "wird nicht als interner oder externer Befehl, betriebsfahiges Programm oder Batch-Datei erkannt",
35 ),
36 ).toBe(true);
37 } finally {
38 Object.defineProperty(process, "platform", { value: originalPlatform, configurable: true });
39 }
40 });
41});