Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

70 строки
3.6KB

  1. <#
  2. .SYNOPSIS
  3. Regression suite for the toolchain, templates, projects, and examples.
  4. .DESCRIPTION
  5. Run after changing tools/, templates/, lib/, or an example:
  6. pwsh tools/regress.ps1 (or: .\c64.cmd is not needed; this calls the module)
  7. Exit code 0 when every case passes. About 2 minutes.
  8. #>
  9. $ErrorActionPreference = "Stop"
  10. Import-Module (Join-Path $PSScriptRoot "C64Tools.psm1") -Force
  11. $root = Split-Path $PSScriptRoot -Parent
  12. Push-Location $root
  13. $scratch = Join-Path ([IO.Path]::GetTempPath()) ("c64-regress-" + [Guid]::NewGuid().ToString("N").Substring(0, 8))
  14. New-Item -ItemType Directory -Path $scratch | Out-Null
  15. $blank = Join-Path $scratch "blank.d64"
  16. & (Get-C64Tool "c1541") -format "work,01" d64 $blank 2>&1 | Out-Null
  17. $cases = @(
  18. @{ Path = "$scratch\t-c"; New = "c" },
  19. @{ Path = "$scratch\t-asm"; New = "asm" },
  20. @{ Path = "$scratch\t-basic"; New = "basic" },
  21. @{ Path = "$scratch\t-c128"; New = "c"; Machine = "c128" },
  22. @{ Path = "skirmish-game" },
  23. @{ Path = "samples/kernal-os-skeleton" },
  24. @{ Path = "samples/kernal-os-skeleton"; Keys = "help\n"; AfterJiffies = 700; Expect = @("ABOUT EXIT") },
  25. @{ Path = "samples/cc65-mouse-driver-demo" },
  26. @{ Path = "examples/hello-world.asm"; Until = "done"; Expect = @("HELLO, WORLD!") },
  27. @{ Path = "examples/kernal-io.asm"; Keys = "hello\n"; Until = "main_done"; Expect = @("YOU TYPED: HELLO") },
  28. @{ Path = "examples/bitmap-demo.asm"; Until = "wait_key" },
  29. @{ Path = "examples/irq-handler.asm"; AfterJiffies = 300; Expect = @("READY.") },
  30. @{ Path = "examples/moonlander.c"; AfterJiffies = 400; Expect = @("MOONLANDER", "PRESS FIRE") },
  31. @{ Path = "examples/linked-list-test.c"; AfterJiffies = 400; Expect = @("N=1000 PASS") },
  32. @{ Path = "examples/sprite-demo.bas"; AfterJiffies = 400 },
  33. @{ Path = "examples/sprite-music-demo.bas"; AfterJiffies = 400 },
  34. @{ Path = "examples/sound-demo.bas"; AfterJiffies = 400 },
  35. @{ Path = "examples/disk-access.bas"; Disk = $blank; Expect = @("READ: LAST RECORD", "BLOCKS FREE", "DONE.") }
  36. )
  37. $results = foreach ($c in $cases) {
  38. $label = if ($c.New) { "template $($c.New)" } else { $c.Path }
  39. if ($c.Machine) { $label += " ($($c.Machine) native)" }
  40. if ($c.ContainsKey("Keys")) { $label += " (keys)" }
  41. try {
  42. if ($c.New) { [void](New-C64Project -Name (Split-Path $c.Path -Leaf) -Template $c.New -Destination $c.Path) }
  43. if ($c.Machine) {
  44. $manifest = Join-Path $c.Path "c64project.json"
  45. $project = Get-Content -Raw -LiteralPath $manifest | ConvertFrom-Json
  46. $project.machine = $c.Machine
  47. $project.disk = $false
  48. $project | ConvertTo-Json -Depth 4 | Set-Content -LiteralPath $manifest
  49. }
  50. $testArgs = @{ Path = $c.Path }
  51. foreach ($k in "Until", "AfterJiffies", "Keys", "Disk", "Expect") { if ($c.ContainsKey($k)) { $testArgs[$k] = $c[$k] } }
  52. $r = Invoke-C64Test @testArgs 6>$null
  53. if ($c.Machine -and $r.screen) { Write-Host $r.screen.TrimEnd() }
  54. [pscustomobject]@{ Case = $label; Passed = $r.passed; Reason = $r.reason; Seconds = $r.seconds }
  55. } catch {
  56. [pscustomobject]@{ Case = $label; Passed = $false; Reason = $_.Exception.Message; Seconds = 0 }
  57. }
  58. }
  59. Pop-Location
  60. Remove-Item -LiteralPath $scratch -Recurse -Force -ErrorAction SilentlyContinue
  61. $results | Format-Table Case, Passed, Seconds, Reason -AutoSize | Out-String -Width 200 | Write-Host
  62. $failed = @($results | Where-Object { -not $_.Passed })
  63. Write-Host ("{0}/{1} passed" -f ($results.Count - $failed.Count), $results.Count) -ForegroundColor $(if ($failed) { "Red" } else { "Green" })
  64. exit $(if ($failed) { 1 } else { 0 })

Powered by TurnKey Linux.