





















@@ -353,10 +353,58 @@ describe("install.ps1 failure handling", () => {
353353expect(interactiveCommandBody).toContain("-NoNewWindow");
354354expect(interactiveCommandBody).toContain("-Wait");
355355expect(interactiveCommandBody).toContain("-PassThru");
356+expect(interactiveCommandBody).toContain("$process.ExitCode -ne 0");
357+expect(interactiveCommandBody).toContain("failed with exit code");
356358expect(mainBody).toContain('Write-Host "Starting setup..." -ForegroundColor Cyan');
357359expect(mainBody).toContain("Invoke-InteractiveOpenClawCommand onboard");
358360});
359361362+runIfPowerShell("fails install when interactive onboarding exits non-zero", () => {
363+const tempDir = harness.createTempDir("openclaw-install-ps1-");
364+const scriptPath = join(tempDir, "install.ps1");
365+const scriptWithoutEntryPoint = source.replace(ENTRYPOINT_RE, "");
366+writeFileSync(
367+scriptPath,
368+[
369+scriptWithoutEntryPoint,
370+"",
371+"function Write-Banner { }",
372+"function Ensure-ExecutionPolicy { return $true }",
373+"function Check-Node { return $true }",
374+"function Check-ExistingOpenClaw { return $false }",
375+"function Get-NpmCommandPath { return 'npm.cmd' }",
376+"function Install-OpenClaw { return $true }",
377+"function Ensure-OpenClawOnPath { return $true }",
378+"function Add-ToUserPath { param([string]$Path) }",
379+"function Get-OpenClawCommandPath { return 'cmd.exe' }",
380+"function Start-Process {",
381+" param([string]$FilePath, [string[]]$ArgumentList, [switch]$NoNewWindow, [switch]$Wait, [switch]$PassThru)",
382+" [pscustomobject]@{ ExitCode = 17 }",
383+"}",
384+"$InstallMethod = 'npm'",
385+"$NoOnboard = $false",
386+"",
387+ ...ENTRYPOINT_LINES,
388+"",
389+].join("\n"),
390+);
391+chmodSync(scriptPath, 0o755);
392+393+const result = runPowerShell([
394+"-NoLogo",
395+"-NoProfile",
396+"-ExecutionPolicy",
397+"Bypass",
398+"-File",
399+scriptPath,
400+]);
401+402+expect(result.status).toBe(1);
403+expect(`${result.stdout}\n${result.stderr}`).toContain(
404+"openclaw onboard failed with exit code 17",
405+);
406+});
407+360408runIfPowerShell("exits non-zero when run as a script file", () => {
361409const tempDir = harness.createTempDir("openclaw-install-ps1-");
362410const scriptPath = join(tempDir, "install.ps1");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。