test(cli): preserve Windows runtime paths and failure diagnostics

Supply the system root and temporary directory in isolated Windows CLI environments, while preserving explicit caller overrides. Include captured command output in web acceptance exit-code failures so startup and codec errors remain diagnosable.
This commit is contained in:
morluto
2026-10-12 15:46:42 +08:00
parent 974f11d010
commit 79156e5bed
3 changed files with 14 additions and 2 deletions
+10
View File
@@ -1,4 +1,5 @@
import { resolve } from "node:path";
import { tmpdir } from "node:os";
import {
createTestWorkspace,
@@ -58,6 +59,15 @@ export const createTestCli = (
cwd: cwd ?? process.cwd(),
env: {
PATH: process.env.PATH ?? "",
// Native Windows APIs need the system root and a writable temporary
// directory even when the command's application environment is empty.
...(process.platform === "win32"
? {
SystemRoot: process.env.SystemRoot,
TEMP: tmpdir(),
TMP: tmpdir(),
}
: {}),
...(compileCache === undefined ||
environment?.NODE_V8_COVERAGE !== undefined
? {}