From c85f9508e71e476ca9a415bbb55c5d1d5e93eb92 Mon Sep 17 00:00:00 2001 From: imengying Date: Sat, 12 Sep 2026 02:49:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=20pwsh=20=E6=B5=8B=E8=AF=95=E5=8A=A0?= =?UTF-8?q?=E6=98=BE=E5=BC=8F=E8=B6=85=E6=97=B6=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=20CI=20=E5=81=B6=E5=8F=91=E8=B6=85=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI 的 ubuntu runner 预装 pwsh,Windows uninstall/update/installer-output 等测试会真实执行。这些测试每次都要冷启动 pwsh 进程,首次调用可超过 bun test 默认的 5 秒单测超时(CI 实测 5151ms 失败)。 为 5 个 pwsh 测试点加 30 秒显式超时;两处原本没有超时的 spawnSync 补 10 秒上限,避免 runner 卡顿时测试无限挂起。 --- frontend/src/install.test.ts | 2 +- frontend/src/installerOutput.test.ts | 8 ++++---- frontend/src/updateSafety.test.ts | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frontend/src/install.test.ts b/frontend/src/install.test.ts index f048fc6..3c21f3f 100644 --- a/frontend/src/install.test.ts +++ b/frontend/src/install.test.ts @@ -131,7 +131,7 @@ describe("Windows uninstall ownership", () => { } finally { rmSync(directory, { recursive: true, force: true }); } - }); + }, 30_000); } }); diff --git a/frontend/src/installerOutput.test.ts b/frontend/src/installerOutput.test.ts index 42ac8ab..218e85a 100644 --- a/frontend/src/installerOutput.test.ts +++ b/frontend/src/installerOutput.test.ts @@ -97,9 +97,9 @@ for (const [name, path, server] of [ $errors = $null [System.Management.Automation.Language.Parser]::ParseFile($env:TEST_SCRIPT, [ref]$tokens, [ref]$errors) > $null if ($errors.Count) { $errors | ForEach-Object { Write-Error $_ }; exit 1 } - `], { env: { ...process.env, TEST_SCRIPT: file }, encoding: "utf8" }); + `], { env: { ...process.env, TEST_SCRIPT: file }, encoding: "utf8", timeout: 10_000 }); expect(result.status).toBe(0); - }); + }, 30_000); test.skipIf(!powershell)("separates fresh-install guidance from update results", () => { const states = server ? [[true, false, false], [false, false, false]] : [ @@ -120,7 +120,7 @@ for (const [name, path, server] of [ $Port = 3100 Write-Step "正在启动服务" Show-InstallResult - `], { encoding: "utf8" }); + `], { encoding: "utf8", timeout: 10_000 }); expect(result.status).toBe(0); const output = result.stdout.replaceAll("\r\n", "\n"); if (fresh) { @@ -130,6 +130,6 @@ for (const [name, path, server] of [ expect(output).toBe("正在启动服务\n\n更新完成(v1.2.3)\n"); } } - }); + }, 30_000); }); } diff --git a/frontend/src/updateSafety.test.ts b/frontend/src/updateSafety.test.ts index 27e70e5..c468e85 100644 --- a/frontend/src/updateSafety.test.ts +++ b/frontend/src/updateSafety.test.ts @@ -239,7 +239,7 @@ describe("Windows update process lifecycle", () => { `], { env: { ...process.env, TEST_MODE: mode }, encoding: "utf8", timeout: 10_000 }); expect(result.status).toBe(mode === "stops" ? 0 : 1); expect(result.stdout.trim()).toBe(mode === "stops" ? "replaced:2" : "blocked"); - }); + }, 30_000); } } @@ -271,5 +271,5 @@ describe("Windows update process lifecycle", () => { } finally { rmSync(directory, { recursive: true, force: true }); } - }); + }, 30_000); });