为 pwsh 测试加显式超时,修复 CI 偶发超时

CI 的 ubuntu runner 预装 pwsh,Windows uninstall/update/installer-output
等测试会真实执行。这些测试每次都要冷启动 pwsh 进程,首次调用可超过
bun test 默认的 5 秒单测超时(CI 实测 5151ms 失败)。

为 5 个 pwsh 测试点加 30 秒显式超时;两处原本没有超时的 spawnSync
补 10 秒上限,避免 runner 卡顿时测试无限挂起。
This commit is contained in:
imengying committed 2026-09-12 02:49:32 +08:00
1 parent 3429d3734b
commit c85f9508e7
3 files changed
+7 -7

No files matched your search

+1 -1
View File
@@ -131,7 +131,7 @@ describe("Windows uninstall ownership", () => {
} finally {
rmSync(directory, { recursive: true, force: true });
}
});
}, 30_000);
}
});
+4 -4
View File
@@ -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);
});
}
+2 -2
View File
@@ -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);
});