Skip to content

Commit a4990e6

Browse files
committed
test(cli): windows cli launch path by host and home
1 parent 899207a commit a4990e6

3 files changed

Lines changed: 29 additions & 3 deletions

File tree

‎.github/checkfast/winlaunch.sh‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
set -u
22
node --import tsx packages/cli/scripts/prepare-process-test-browser.mjs
33
export HYPERFRAMES_BROWSER_PATH=$(grep HYPERFRAMES_BROWSER_PATH "$GITHUB_ENV" | tail -1 | cut -d= -f2-)
4-
cd packages/cli && npx vitest run src/winpipe.debug.test.ts --maxWorkers=1 2>&1 | grep WINPIPE
5-
echo "--- same script from plain node (no vitest):"
6-
node -e 'const {spawnSync}=require("child_process");for(const m of ["pipe","port"]){const r=spawnSync(process.execPath,["-e",`import("puppeteer-core").then(async({default:p})=>{const s=Date.now();try{const b=await p.launch({executablePath:process.env.HYPERFRAMES_BROWSER_PATH,headless:true,pipe:"${m}"==="pipe",args:["--no-sandbox"],timeout:30000});await (await b.newPage()).evaluate(()=>1);console.log("OK "+(Date.now()-s));await b.close()}catch(e){console.log("FAIL "+(Date.now()-s)+" "+e.message.split("\\n")[0])}process.exit(0)})`],{encoding:"utf8"});console.log("PLAIN "+m+": "+r.stdout.trim())}'
4+
cd packages/cli
5+
echo "--- outside vitest:"
6+
for gpu in software hardware; do echo "PLAINCLI gpu=$gpu: $(node --import tsx src/wincli.debug.ts $gpu 2>&1 | tr '\n' ' ' | cut -c1-1500)"; done
7+
npx vitest run src/wincli.debug.test.ts --maxWorkers=1 2>&1 | grep WINCLI
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { spawnSync } from "node:child_process";
2+
import { join } from "node:path";
3+
import { it } from "vitest";
4+
5+
it("cli launch path by host and home", () => {
6+
const realHome = `${process.env.HOMEDRIVE}${process.env.HOMEPATH}`;
7+
console.error(`WINCLI vitest USERPROFILE=${process.env.USERPROFILE} real=${realHome} pinned=${process.env.HYPERFRAMES_BROWSER_PATH}`);
8+
for (const gpu of ["software", "hardware"]) {
9+
for (const home of ["temp", "real"]) {
10+
const env = { ...process.env, ...(home === "real" ? { USERPROFILE: realHome, HOME: realHome } : {}) };
11+
const r = spawnSync(process.execPath, ["--import", "tsx", join("src", "wincli.debug.ts"), gpu], { env, encoding: "utf8", timeout: 120_000 });
12+
console.error(`WINCLI gpu=${gpu} home=${home}: ${r.stdout.trim().replace(/\n/g, " | ").slice(0, 1500)} ${r.stderr.trim().split("\n").slice(-2).join(" / ").slice(0, 300)}`);
13+
}
14+
}
15+
}, 900_000);

‎packages/cli/src/wincli.debug.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { prelaunchCompositionBrowser } from "./capture/captureCompositionFrame.js";
2+
const html = `<!doctype html><html><body><div data-composition-id="main" data-width="320" data-height="180" data-duration="1"><p>x</p></div></body></html>`;
3+
const start = Date.now();
4+
const handle = prelaunchCompositionBrowser(html, (process.argv[2] as never) || undefined);
5+
const result = await handle.launched;
6+
const args = result?.browser.process()?.spawnargs ?? [];
7+
console.log(`${result ? "OK" : "FAIL"} ${Date.now() - start} pipe=${args.includes("--remote-debugging-pipe")} exe=${args[0]}`);
8+
console.log(`ARGS ${args.slice(1).join(" ")}`);
9+
await result?.browser.close();
10+
process.exit(0);

0 commit comments

Comments
 (0)