@@ -8,7 +8,10 @@ import { describe, expect, it } from "vitest";
|
8 | 8 | const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../.."); |
9 | 9 | const scriptPath = path.join(repoRoot, "scripts/e2e/lib/run-with-pty.mjs"); |
10 | 10 | |
11 | | -function runPtyProbe(logPath: string): Promise<{ code: number | null; stdout: string; stderr: string }> { |
| 11 | +function runPtyProbe( |
| 12 | +logPath: string, |
| 13 | +env: Record<string, string> = {}, |
| 14 | +): Promise<{ code: number | null; stdout: string; stderr: string }> { |
12 | 15 | return new Promise((resolve, reject) => { |
13 | 16 | const child = spawn( |
14 | 17 | process.execPath, |
@@ -19,7 +22,7 @@ function runPtyProbe(logPath: string): Promise<{ code: number | null; stdout: st
|
19 | 22 | "-lc", |
20 | 23 | 'printf "prompt\\n"; IFS= read -r value; printf "got:%s\\n" "$value"', |
21 | 24 | ], |
22 | | -{ stdio: ["pipe", "pipe", "pipe"] }, |
| 25 | +{ env: { ...process.env, ...env }, stdio: ["pipe", "pipe", "pipe"] }, |
23 | 26 | ); |
24 | 27 | let stdout = ""; |
25 | 28 | let stderr = ""; |
@@ -49,6 +52,19 @@ function runPtyProbe(logPath: string): Promise<{ code: number | null; stdout: st
|
49 | 52 | } |
50 | 53 | |
51 | 54 | describe("run-with-pty", () => { |
| 55 | +it("rejects loose terminal dimension env values", async () => { |
| 56 | +const tempRoot = await mkdtemp(path.join(os.tmpdir(), "openclaw-run-with-pty-")); |
| 57 | +const logPath = path.join(tempRoot, "pty.log"); |
| 58 | +try { |
| 59 | +const result = await runPtyProbe(logPath, { COLUMNS: "120cols" }); |
| 60 | + |
| 61 | +expect(result.code).not.toBe(0); |
| 62 | +expect(result.stderr).toContain("invalid COLUMNS: 120cols"); |
| 63 | +} finally { |
| 64 | +await rm(tempRoot, { recursive: true, force: true }); |
| 65 | +} |
| 66 | +}); |
| 67 | + |
52 | 68 | it("forwards stdin through a PTY and writes the transcript log", async () => { |
53 | 69 | const tempRoot = await mkdtemp(path.join(os.tmpdir(), "openclaw-run-with-pty-")); |
54 | 70 | const logPath = path.join(tempRoot, "pty.log"); |
|