@@ -423,9 +423,13 @@ exit 1
|
423 | 423 | |
424 | 424 | it("cleans timed-out Windows background work and reads bounded log chunks", async () => { |
425 | 425 | const decodedCommands: string[] = []; |
426 | | -const fakeRun: typeof hostCommandRun = (_command, args) => { |
| 426 | +const inputs: string[] = []; |
| 427 | +const fakeRun: typeof hostCommandRun = (_command, args, options) => { |
427 | 428 | const decoded = decodePowerShellFromArgs(args); |
428 | 429 | decodedCommands.push(decoded); |
| 430 | +if (options?.input) { |
| 431 | +inputs.push(String(options.input)); |
| 432 | +} |
429 | 433 | if (decoded.includes("Start-Process")) { |
430 | 434 | return { status: 0, stderr: "", stdout: "started\n" }; |
431 | 435 | } |
@@ -445,7 +449,13 @@ exit 1
|
445 | 449 | ).rejects.toThrow("windows background timeout timed out"); |
446 | 450 | |
447 | 451 | const commands = decodedCommands.join("\n---\n"); |
| 452 | +const payloads = inputs.join("\n---\n"); |
448 | 453 | expect(commands).toContain("$pidPath"); |
| 454 | +expect(commands).toContain("function Write-OpenClawUtf8File"); |
| 455 | +expect(commands).toContain("[System.Text.UTF8Encoding]::new($false)"); |
| 456 | +expect(payloads).toContain("Write-OpenClawUtf8File $exitPath '0'"); |
| 457 | +expect(payloads).toContain("Write-OpenClawUtf8File $donePath 'done'"); |
| 458 | +expect(commands).toContain("Write-OpenClawUtf8File $pidPath ([string]$process.Id)"); |
449 | 459 | expect(commands).toContain("Start-Process -FilePath powershell.exe"); |
450 | 460 | expect(commands).toContain("-PassThru"); |
451 | 461 | expect(commands).toContain("[System.IO.File]::Open($logPath"); |
@@ -457,6 +467,9 @@ exit 1
|
457 | 467 | expect(commands).toContain( |
458 | 468 | "Remove-Item -Path $scriptPath, $logPath, $donePath, $exitPath, $pidPath", |
459 | 469 | ); |
| 470 | +expect(`${commands}\n${payloads}`).not.toContain("Set-Content -Path $exitPath"); |
| 471 | +expect(`${commands}\n${payloads}`).not.toContain("Set-Content -Path $donePath"); |
| 472 | +expect(commands).not.toContain("Set-Content -Path $pidPath"); |
460 | 473 | expect(commands).not.toContain("ReadAllBytes"); |
461 | 474 | }); |
462 | 475 | |
|