Skip to content

Commit 316c4e5

Browse files
committed
test(cli): warm launch under each windows harness variant
1 parent 9e374e8 commit 316c4e5

2 files changed

Lines changed: 32 additions & 11 deletions

File tree

‎.github/checkfast/winlaunch.sh‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,2 @@
1-
# Cold check launch on Windows: bin vs tsx, with and without --no-browser-gpu.
21
set -u
3-
cd packages/cli
4-
FX=$RUNNER_TEMP/fx; mkdir -p $FX
5-
printf '%s' '<!doctype html><html><body><div data-composition-id="main" data-width="320" data-height="180" data-duration="1"><p style="color:#fff;background:#000">Warm</p></div><script>window.__timelines={main:{duration:()=>1,seek:()=>{},pause:()=>{}}};</script></body></html>' > $FX/index.html
6-
t() { label=$1; shift; s=$(node -e 'console.log(Date.now())'); CI=1 "$@" > $RUNNER_TEMP/$label.out 2> $RUNNER_TEMP/$label.err; code=$?; e=$(node -e 'console.log(Date.now())'); echo "$label exit=$code ms=$((e-s)) $(grep -o '"message": *"[^"]*"' $RUNNER_TEMP/$label.out | head -2 | tr '\n' ' ')"; tail -2 $RUNNER_TEMP/$label.err | cut -c1-300; }
7-
for i in 1 2; do
8-
t bin-gpu$i node bin/hyperframes.mjs check $FX --json --samples=1
9-
t bin-nogpu$i node bin/hyperframes.mjs check $FX --json --samples=1 --no-browser-gpu
10-
t tsx-gpu$i node --import tsx src/cli.ts check $FX --json --samples=1
11-
t tsx-nogpu$i node --import tsx src/cli.ts check $FX --json --samples=1 --no-browser-gpu
12-
done
2+
node .github/checkfast/winwarm.mjs

‎.github/checkfast/winwarm.mjs‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Spawns the warm process under each harness variant and reports whether its Chrome finished starting.
2+
import { spawn, execFileSync } from "node:child_process";
3+
import { mkdtempSync, writeFileSync, readFileSync, existsSync } from "node:fs";
4+
import { tmpdir } from "node:os";
5+
import { join } from "node:path";
6+
const cli = join(process.cwd(), "packages/cli");
7+
const fx = mkdtempSync(join(tmpdir(), "fx-"));
8+
writeFileSync(join(fx, "index.html"), `<!doctype html><html><body><div data-composition-id="main" data-width="320" data-height="180" data-duration="1"><p>Warm</p></div><script>window.__timelines={main:{duration:()=>1,seek:()=>{},pause:()=>{}}};</script></body></html>`);
9+
const variants = [];
10+
for (const entry of ["tsx", "dist"]) for (const stdio of ["pipe", "ignore"]) for (const detached of [false, true]) for (const lad of ["inherit", "temp"]) variants.push({ entry, stdio, detached, lad });
11+
for (const v of variants) {
12+
const log = join(mkdtempSync(join(tmpdir(), "dbg-")), "log.txt");
13+
const env = { ...process.env, HF_WARM_DBG: log, HYPERFRAMES_NO_TELEMETRY: "1" };
14+
if (v.lad === "temp") env.LOCALAPPDATA = mkdtempSync(join(tmpdir(), "lad-"));
15+
const args = v.entry === "tsx" ? ["--import", "tsx", "src/warmCheck.ts"] : ["dist/warmCheck.js"];
16+
const start = Date.now();
17+
const child = spawn(process.execPath, [...args, "60000", fx, "--json", "--no-browser-gpu", "--samples=1"], {
18+
cwd: cli, env, detached: v.detached, stdio: v.stdio === "pipe" ? ["ignore", "pipe", "pipe"] : "ignore", windowsHide: true,
19+
});
20+
child.stdout?.on("data", () => {}); child.stderr?.on("data", () => {});
21+
let result = "timeout";
22+
while (Date.now() - start < 45_000) {
23+
const text = existsSync(log) ? readFileSync(log, "utf8") : "";
24+
const m = text.match(/launched (true|false)/);
25+
if (m) { result = m[1] === "true" ? "LAUNCHED" : "FAILED"; break; }
26+
await new Promise((r) => setTimeout(r, 200));
27+
}
28+
console.log(JSON.stringify(v), result, `${Date.now() - start} ms`);
29+
try { execFileSync("taskkill", ["/T", "/F", "/PID", String(child.pid)], { stdio: "ignore" }); } catch {}
30+
await new Promise((r) => setTimeout(r, 1000));
31+
}

0 commit comments

Comments
 (0)