|
- <#
- .SYNOPSIS
- Regression suite for the toolchain, templates, projects, and examples.
-
- .DESCRIPTION
- Run after changing tools/, templates/, lib/, or an example:
- pwsh tools/regress.ps1 (or: .\c64.cmd is not needed; this calls the module)
- Exit code 0 when every case passes. About 2 minutes.
- #>
- $ErrorActionPreference = "Stop"
- Import-Module (Join-Path $PSScriptRoot "C64Tools.psm1") -Force
- $root = Split-Path $PSScriptRoot -Parent
- Push-Location $root
- $scratch = Join-Path ([IO.Path]::GetTempPath()) ("c64-regress-" + [Guid]::NewGuid().ToString("N").Substring(0, 8))
- New-Item -ItemType Directory -Path $scratch | Out-Null
-
- $blank = Join-Path $scratch "blank.d64"
- & (Get-C64Tool "c1541") -format "work,01" d64 $blank 2>&1 | Out-Null
-
- $cases = @(
- @{ Path = "$scratch\t-c"; New = "c" },
- @{ Path = "$scratch\t-asm"; New = "asm" },
- @{ Path = "$scratch\t-basic"; New = "basic" },
- @{ Path = "$scratch\t-c128"; New = "c"; Machine = "c128" },
- @{ Path = "skirmish-game" },
- @{ Path = "samples/kernal-os-skeleton" },
- @{ Path = "samples/kernal-os-skeleton"; Keys = "help\n"; AfterJiffies = 700; Expect = @("ABOUT EXIT") },
- @{ Path = "samples/cc65-mouse-driver-demo" },
- @{ Path = "examples/hello-world.asm"; Until = "done"; Expect = @("HELLO, WORLD!") },
- @{ Path = "examples/kernal-io.asm"; Keys = "hello\n"; Until = "main_done"; Expect = @("YOU TYPED: HELLO") },
- @{ Path = "examples/bitmap-demo.asm"; Until = "wait_key" },
- @{ Path = "examples/irq-handler.asm"; AfterJiffies = 300; Expect = @("READY.") },
- @{ Path = "examples/moonlander.c"; AfterJiffies = 400; Expect = @("MOONLANDER", "PRESS FIRE") },
- @{ Path = "examples/linked-list-test.c"; AfterJiffies = 400; Expect = @("N=1000 PASS") },
- @{ Path = "examples/sprite-demo.bas"; AfterJiffies = 400 },
- @{ Path = "examples/sprite-music-demo.bas"; AfterJiffies = 400 },
- @{ Path = "examples/sound-demo.bas"; AfterJiffies = 400 },
- @{ Path = "examples/disk-access.bas"; Disk = $blank; Expect = @("READ: LAST RECORD", "BLOCKS FREE", "DONE.") }
- )
-
- $results = foreach ($c in $cases) {
- $label = if ($c.New) { "template $($c.New)" } else { $c.Path }
- if ($c.Machine) { $label += " ($($c.Machine) native)" }
- if ($c.ContainsKey("Keys")) { $label += " (keys)" }
- try {
- 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 }
- foreach ($k in "Until", "AfterJiffies", "Keys", "Disk", "Expect") { if ($c.ContainsKey($k)) { $testArgs[$k] = $c[$k] } }
- $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 }
- } catch {
- [pscustomobject]@{ Case = $label; Passed = $false; Reason = $_.Exception.Message; Seconds = 0 }
- }
- }
-
- Pop-Location
- Remove-Item -LiteralPath $scratch -Recurse -Force -ErrorAction SilentlyContinue
- $results | Format-Table Case, Passed, Seconds, Reason -AutoSize | Out-String -Width 200 | Write-Host
- $failed = @($results | Where-Object { -not $_.Passed })
- Write-Host ("{0}/{1} passed" -f ($results.Count - $failed.Count), $results.Count) -ForegroundColor $(if ($failed) { "Red" } else { "Green" })
- exit $(if ($failed) { 1 } else { 0 })
|