Repository navigation
feat: Compare generated code against reference files for tests. Provide metrics for some aspects of the generated code - #2348
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
One or more issues must be addressed before approval.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds generated-code golden snapshots and Roslyn-based metrics to strengthen code-generator regression testing.
Changes:
- Compares generated C# against committed reference files.
- Exposes compilation artifacts and records syntax/diagnostic metrics.
- Documents golden regeneration.
File summaries
| File | Description |
|---|---|
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/strings.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/sticli.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/speculative_smc_guard.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/speculative_mixed_block.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/speculative_invalid_opcode.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/speculative_discard.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/speculative_convergence.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/speculative_closure.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/speculative_call_entry.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/speculative_branch.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/selfmodifyvalue.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/selfmodifyterminator.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/selfmodifyje.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/selfmodifyinstructions.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/selfmodifycalltarget.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/selfmodifycall.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/segpr.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/returnedterminator.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/pushcs_callnear_retfar.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/partition_shared_tail.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/partition_mutual_recursion_unwind.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/partition_multi_entry_irreducible_shared.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/partition_multi_entry_dominated_shared.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/partition_mixed_activation_cycle.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/partition_jump_into_function_middle.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/partition_indirect_call_jump.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/partition_cross_function_loop.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/multimisalignedcall.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/lockprefix.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/linearsamesegmenteddifferent.a20.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/jump2.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/jmpmov.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/interrupt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/intchain.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/externalint.pit.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/divfaultloop.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/div2.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/datatrnf.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/control.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/cmpneg.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/GeneratedOverrideCompiler.cs | Updated as part of this pull request. |
| tests/Spice86.Tests/GeneratedCompilation.cs | Updated as part of this pull request. |
| tests/Spice86.Tests/GeneratedCodeMetricsCollector.cs | Updated as part of this pull request. |
| tests/Spice86.Tests/GeneratedCodeMetrics.cs | Updated as part of this pull request. |
| tests/Spice86.Tests/GeneratedCodeMachineTestRunner.cs | Updated as part of this pull request. |
| AGENTS.md | Updated as part of this pull request. |
Review details
Suppressed comments (2)
tests/Spice86.Tests/GeneratedCodeMachineTestRunner.cs:65
MaxCyclesandConfigureMachineare omitted from this key even though both are passed intoGenerateProgramand can change the discovered CFG and generated source. Two tests using the same binary and flags with different values will therefore share one golden and can validate against the wrong scenario; include every source-affecting input in the key or require callers to provide a distinct key.
/// overwriting each other. <c>MaxCycles</c> and <c>ConfigureMachine</c> are deliberately not part
/// of the key. Every flag is enumerated explicitly so adding one to the options is a
/// compile-visible decision here rather than a silent omission that lets two runs share a golden.
tests/Spice86.Tests/GeneratedCodeMachineTestRunner.cs:124
- This new helper adds an optional/defaulted parameter, contrary to the repository's no-optional-parameters guidance. Keep the regeneration-only path explicit instead of introducing a callable-without-a-path API here.
private static string GetSourceFilePath([CallerFilePath] string path = "") => path;
- Files reviewed: 56/57 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
maximilien-noal
approved these changes
Sep 16, 2026
…de metrics for some aspects of the generated code
kevinferrare
force-pushed
the
feature/generated_code_measures_in_tests
branch
from
September 16, 2026 06:32
cf3ad3b to
b8a6365
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Preliminary phase for code generator improvements