Capture vice.log and redirected stdout/stderr, record the emulator exit code in result.json, and report launch failures and early exits clearly. Pass -AfterJiffies to the monitor in hex. Add a native C128 case to the regression suite and document the 40-column-only text check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>refactor/agent-workflow
| @@ -125,7 +125,12 @@ with the stored value) if you need a bare-VICE check. | |||||
| | `ram.bin` | 64KB RAM, banking ignored (2-byte load-address header, then $0000-$FFFF) | | | `ram.bin` | 64KB RAM, banking ignored (2-byte load-address header, then $0000-$FFFF) | | ||||
| | `io.bin` | $D000-$DFFF as the CPU sees I/O: VIC, SID, color RAM, CIAs (2-byte header) | | | `io.bin` | $D000-$DFFF as the CPU sees I/O: VIC, SID, color RAM, CIAs (2-byte header) | | ||||
| | `monitor.log` | VICE monitor output. The `.;xxxx` line holds PC/A/X/Y at the trigger | | | `monitor.log` | VICE monitor output. The `.;xxxx` line holds PC/A/X/Y at the trigger | | ||||
| | `result.json` | `passed`, `reason`, `code`, `pc`, `missing`, `screen` | | |||||
| | `vice.log`, `vice.stdout.log`, `vice.stderr.log` | VICE startup and runtime diagnostics, when emitted | | |||||
| | `result.json` | `passed`, `reason`, `code`, `pc`, `missing`, `screen`, `emulatorExitCode` | | |||||
| On a native C128, `-Expect` checks the 40-column VIC-II screen. The 80-column | |||||
| VDC screen is outside the text decoder's coverage. A native 40-column smoke | |||||
| test runs in `tools/regress.ps1`. | |||||
| Inspect a variable: find it in `build/<name>.lbl`, then read `ram.bin` at | Inspect a variable: find it in `build/<name>.lbl`, then read `ram.bin` at | ||||
| `2 + address`. For example, with pwsh: | `2 + address`. For example, with pwsh: | ||||
| @@ -43,7 +43,7 @@ c64 mon "r" "m .label .label+8" # talk to a run started with -Monito | |||||
| - **Free zero page** while BASIC and the Kernal are live: `$02`, `$FB-$FE`. cc65 C | - **Free zero page** while BASIC and the Kernal are live: `$02`, `$FB-$FE`. cc65 C | ||||
| programs own `$02-$1B` for their runtime. | programs own `$02-$1B` for their runtime. | ||||
| - **Keep the suite green.** After changing `tools/`, `templates/`, `lib/`, or an example, | - **Keep the suite green.** After changing `tools/`, `templates/`, `lib/`, or an example, | ||||
| run `pwsh tools/regress.ps1` (about 2 minutes, 17 cases). | |||||
| run `pwsh tools/regress.ps1` (about 2 minutes, including a native C128 smoke test). | |||||
| - **Respect sub-project rules.** `newLang/` has its own `AGENTS.md`; read it before | - **Respect sub-project rules.** `newLang/` has its own `AGENTS.md`; read it before | ||||
| changing anything there. | changing anything there. | ||||
| @@ -76,8 +76,16 @@ waits for a trigger: | |||||
| - **`-AfterJiffies <n>`**: after n Kernal IRQs, for programs you don't want to modify. | - **`-AfterJiffies <n>`**: after n Kernal IRQs, for programs you don't want to modify. | ||||
| At the trigger it saves RAM, I/O, the decoded text screen, and a screenshot to | At the trigger it saves RAM, I/O, the decoded text screen, and a screenshot to | ||||
| `build/test/<name>/`, then checks `-Expect` strings. BASIC errors fail immediately | |||||
| with the error name and line number. | |||||
| `build/test/<name>/`, then checks `-Expect` strings against the 40-column VIC-II | |||||
| screen. On a native C128, use the 40-column display for text assertions. The runner | |||||
| does not decode the 80-column VDC screen. The regression suite includes a native | |||||
| C128 build and 40-column text assertion. C64 BASIC errors fail immediately with | |||||
| the error name and line number. | |||||
| If VICE exits before the trigger, check `result.json` for `emulatorExitCode` and | |||||
| look in `vice.log`, `vice.stdout.log`, and `vice.stderr.log` for startup details. | |||||
| The redirected output files may be empty on Windows. Run VICE from a Windows | |||||
| session that allows desktop applications if it exits immediately inside a sandbox. | |||||
| ## Sources | ## Sources | ||||
| @@ -480,7 +480,8 @@ function Invoke-C64Test { | |||||
| } elseif ($AfterJiffies -gt 0) { | } elseif ($AfterJiffies -gt 0) { | ||||
| $mode = "jiffies" | $mode = "jiffies" | ||||
| $tick = if ($TickAddress) { $TickAddress.TrimStart('$') } elseif ($t.Machine -eq "c128") { "fa65" } else { "ea31" } | $tick = if ($TickAddress) { $TickAddress.TrimStart('$') } elseif ($t.Machine -eq "c128") { "fa65" } else { "ea31" } | ||||
| $trigger = "break exec $tick`nignore 1 $AfterJiffies" | |||||
| # The VICE monitor reads numbers as hex: pass the count in hex. | |||||
| $trigger = "break exec $tick`nignore 1 {0:x}" -f $AfterJiffies | |||||
| } | } | ||||
| $onHit = @( | $onHit = @( | ||||
| @@ -504,11 +505,15 @@ function Invoke-C64Test { | |||||
| Set-Content -Encoding ascii -LiteralPath (Join-Path $out "setup.mon") -Value $setup | Set-Content -Encoding ascii -LiteralPath (Join-Path $out "setup.mon") -Value $setup | ||||
| $log = Join-Path $out "monitor.log" | $log = Join-Path $out "monitor.log" | ||||
| $viceLog = Join-Path $out "vice.log" | |||||
| $stdout = Join-Path $out "vice.stdout.log" | |||||
| $stderr = Join-Path $out "vice.stderr.log" | |||||
| $shot = Join-Path $out "screenshot.png" | $shot = Join-Path $out "screenshot.png" | ||||
| # -refreshonbreak: warp mode skips rendering frames, so without it the exit | # -refreshonbreak: warp mode skips rendering frames, so without it the exit | ||||
| # screenshot can be several frames older than the RAM dump. | # screenshot can be several frames older than the RAM dump. | ||||
| $argv = @("-default", "-sounddev", "dummy", "-minimized", "-warp", "-refreshonbreak", | $argv = @("-default", "-sounddev", "dummy", "-minimized", "-warp", "-refreshonbreak", | ||||
| "-limitcycles", "$MaxCycles", | "-limitcycles", "$MaxCycles", | ||||
| "-logfile", ('"' + $viceLog + '"'), | |||||
| "-moncommands", ('"' + (Join-Path $out "setup.mon") + '"'), | "-moncommands", ('"' + (Join-Path $out "setup.mon") + '"'), | ||||
| "-monlog", "-monlogname", ('"' + $log + '"'), | "-monlog", "-monlogname", ('"' + $log + '"'), | ||||
| "-exitscreenshot", ('"' + $shot + '"')) | "-exitscreenshot", ('"' + $shot + '"')) | ||||
| @@ -522,25 +527,41 @@ function Invoke-C64Test { | |||||
| $emu = Get-C64Tool (Get-C64Emulator $t.Machine) | $emu = Get-C64Tool (Get-C64Emulator $t.Machine) | ||||
| Write-Host ("> {0} {1}" -f (Split-Path $emu -Leaf), ($argv -join ' ')) -ForegroundColor DarkGray | Write-Host ("> {0} {1}" -f (Split-Path $emu -Leaf), ($argv -join ' ')) -ForegroundColor DarkGray | ||||
| $sw = [Diagnostics.Stopwatch]::StartNew() | $sw = [Diagnostics.Stopwatch]::StartNew() | ||||
| $proc = Start-Process -FilePath $emu -ArgumentList $argv -PassThru | |||||
| $done = Join-Path $out "done.bin" | $done = Join-Path $out "done.bin" | ||||
| while (-not $proc.HasExited -and -not (Test-Path -LiteralPath $done) -and $sw.Elapsed.TotalSeconds -lt $TimeoutSeconds) { | |||||
| Start-Sleep -Milliseconds 100 | |||||
| $proc = $null | |||||
| $launchError = $null | |||||
| try { | |||||
| $proc = Start-Process -FilePath $emu -ArgumentList $argv -PassThru -WindowStyle Hidden ` | |||||
| -RedirectStandardOutput $stdout -RedirectStandardError $stderr -ErrorAction Stop | |||||
| } catch { | |||||
| $launchError = $_.Exception.Message | |||||
| } | } | ||||
| $captured = Test-Path -LiteralPath $done | |||||
| if (-not $proc.HasExited) { | |||||
| # A clean close flushes the monitor log and writes the exit screenshot. | |||||
| [void]$proc.CloseMainWindow() | |||||
| if (-not $proc.WaitForExit(10000)) { $proc.Kill(); $proc.WaitForExit() } | |||||
| $timedOut = $false | |||||
| if ($proc) { | |||||
| while (-not $proc.HasExited -and -not (Test-Path -LiteralPath $done) -and $sw.Elapsed.TotalSeconds -lt $TimeoutSeconds) { | |||||
| Start-Sleep -Milliseconds 100 | |||||
| } | |||||
| $timedOut = -not $proc.HasExited -and -not (Test-Path -LiteralPath $done) | |||||
| # Let monitor playback finish its quit command and flush the logs and screenshot. | |||||
| if (-not $timedOut) { [void]$proc.WaitForExit(10000) } | |||||
| if (-not $proc.HasExited) { | |||||
| [void]$proc.CloseMainWindow() | |||||
| if (-not $proc.WaitForExit(10000)) { $proc.Kill(); $proc.WaitForExit() } | |||||
| } | |||||
| } | } | ||||
| $captured = Test-Path -LiteralPath $done | |||||
| $seconds = [math]::Round($sw.Elapsed.TotalSeconds, 1) | $seconds = [math]::Round($sw.Elapsed.TotalSeconds, 1) | ||||
| $result = [ordered]@{ program = $t.Program; mode = $mode; passed = $false; reason = ""; code = $null | $result = [ordered]@{ program = $t.Program; mode = $mode; passed = $false; reason = ""; code = $null | ||||
| seconds = $seconds; screen = $null; missing = @(); pc = $null } | |||||
| seconds = $seconds; screen = $null; missing = @(); pc = $null | |||||
| emulatorExitCode = $(if ($proc) { $proc.ExitCode }) } | |||||
| $reasons = @() | $reasons = @() | ||||
| if (-not $captured) { | |||||
| $why = if ($sw.Elapsed.TotalSeconds -ge $TimeoutSeconds) { "wall-clock timeout ($TimeoutSeconds s)" } else { "emulator stopped after $MaxCycles cycles" } | |||||
| $reasons += "trigger never fired: $why" | |||||
| if ($launchError) { | |||||
| $reasons += "could not start VICE: $launchError" | |||||
| } elseif ($timedOut) { | |||||
| $reasons += "trigger never fired: wall-clock timeout ($TimeoutSeconds s)" | |||||
| } elseif (-not $captured) { | |||||
| $reasons += "trigger never fired: VICE exited with code $($result.emulatorExitCode); see vice.log and vice.stdout.log / vice.stderr.log" | |||||
| } else { | } else { | ||||
| $screen = Read-C64Screen -DumpDir $out | $screen = Read-C64Screen -DumpDir $out | ||||
| Set-Content -LiteralPath (Join-Path $out "screen.txt") -Value $screen.Text -Encoding utf8 | Set-Content -LiteralPath (Join-Path $out "screen.txt") -Value $screen.Text -Encoding utf8 | ||||
| @@ -21,6 +21,7 @@ $cases = @( | |||||
| @{ Path = "$scratch\t-c"; New = "c" }, | @{ Path = "$scratch\t-c"; New = "c" }, | ||||
| @{ Path = "$scratch\t-asm"; New = "asm" }, | @{ Path = "$scratch\t-asm"; New = "asm" }, | ||||
| @{ Path = "$scratch\t-basic"; New = "basic" }, | @{ Path = "$scratch\t-basic"; New = "basic" }, | ||||
| @{ Path = "$scratch\t-c128"; New = "c"; Machine = "c128" }, | |||||
| @{ Path = "skirmish-game" }, | @{ Path = "skirmish-game" }, | ||||
| @{ Path = "samples/kernal-os-skeleton" }, | @{ Path = "samples/kernal-os-skeleton" }, | ||||
| @{ Path = "samples/kernal-os-skeleton"; Keys = "help\n"; AfterJiffies = 700; Expect = @("ABOUT EXIT") }, | @{ Path = "samples/kernal-os-skeleton"; Keys = "help\n"; AfterJiffies = 700; Expect = @("ABOUT EXIT") }, | ||||
| @@ -39,12 +40,21 @@ $cases = @( | |||||
| $results = foreach ($c in $cases) { | $results = foreach ($c in $cases) { | ||||
| $label = if ($c.New) { "template $($c.New)" } else { $c.Path } | $label = if ($c.New) { "template $($c.New)" } else { $c.Path } | ||||
| if ($c.Machine) { $label += " ($($c.Machine) native)" } | |||||
| if ($c.ContainsKey("Keys")) { $label += " (keys)" } | if ($c.ContainsKey("Keys")) { $label += " (keys)" } | ||||
| try { | try { | ||||
| if ($c.New) { [void](New-C64Project -Name (Split-Path $c.Path -Leaf) -Template $c.New -Destination $c.Path) } | if ($c.New) { [void](New-C64Project -Name (Split-Path $c.Path -Leaf) -Template $c.New -Destination $c.Path) } | ||||
| if ($c.Machine) { | |||||
| $manifest = Join-Path $c.Path "c64project.json" | |||||
| $project = Get-Content -Raw -LiteralPath $manifest | ConvertFrom-Json | |||||
| $project.machine = $c.Machine | |||||
| $project.disk = $false | |||||
| $project | ConvertTo-Json -Depth 4 | Set-Content -LiteralPath $manifest | |||||
| } | |||||
| $testArgs = @{ Path = $c.Path } | $testArgs = @{ Path = $c.Path } | ||||
| foreach ($k in "Until", "AfterJiffies", "Keys", "Disk", "Expect") { if ($c.ContainsKey($k)) { $testArgs[$k] = $c[$k] } } | foreach ($k in "Until", "AfterJiffies", "Keys", "Disk", "Expect") { if ($c.ContainsKey($k)) { $testArgs[$k] = $c[$k] } } | ||||
| $r = Invoke-C64Test @testArgs 6>$null | $r = Invoke-C64Test @testArgs 6>$null | ||||
| if ($c.Machine -and $r.screen) { Write-Host $r.screen.TrimEnd() } | |||||
| [pscustomobject]@{ Case = $label; Passed = $r.passed; Reason = $r.reason; Seconds = $r.seconds } | [pscustomobject]@{ Case = $label; Passed = $r.passed; Reason = $r.reason; Seconds = $r.seconds } | ||||
| } catch { | } catch { | ||||
| [pscustomobject]@{ Case = $label; Passed = $false; Reason = $_.Exception.Message; Seconds = 0 } | [pscustomobject]@{ Case = $label; Passed = $false; Reason = $_.Exception.Message; Seconds = 0 } | ||||
Powered by TurnKey Linux.