Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
202cb20 to
781bbb8
Compare
PR SummaryLow Risk Overview 14 Docs in Reviewed by Cursor Bugbot for commit ba42234. Bugbot is set up for automated code reviews on this repo. Configure here. |
35e00fe to
512169c
Compare
eytan-starkware
left a comment
There was a problem hiding this comment.
@eytan-starkware reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: 1 of 20 files reviewed, 1 unresolved discussion (waiting on orizi and TomerStarkware).
.claude/skills/writing-tests/references/golden-framework.md line 213 at r2 (raw file):
Variants: `run_lowering_phases_test_with_db` (pre-configured database, e.g. setting a flag) and `run_lowering_phases_test_with_extra_outputs` (extra output tags derived from the two bodies).
Variant text is not very informative on what they do. Is it elsewhere in the skill?
TomerStarkware
left a comment
There was a problem hiding this comment.
@TomerStarkware reviewed 20 files and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on orizi).
…fore/after phase test runner
512169c to
ba42234
Compare
orizi
left a comment
There was a problem hiding this comment.
@orizi made 1 comment.
Reviewable status: 19 of 20 files reviewed, 1 unresolved discussion (waiting on eytan-starkware and TomerStarkware).
.claude/skills/writing-tests/references/golden-framework.md line 213 at r2 (raw file):
Previously, eytan-starkware wrote…
Variant text is not very informative on what they do. Is it elsewhere in the skill?
Two variants take one extra parameter each, for tests the plain entry point cannot express:
run_lowering_phases_test_with_db(db, inputs, stage, before_phases, after_phases)— runs on the
LoweringDatabaseForTestingyou pass in instead of a default one, for tests that must configure
the database before the test function is lowered.early_unsafe_panic_test.rsuses it to set
Flag::UnsafePanic.run_lowering_phases_test_with_extra_outputs(inputs, stage, before_phases, after_phases, extra_outputs)—extra_outputsis a|before, after| -> Vec<(String, String)>closure whose
entries are appended as output tags after the standard four; it is not called if the function
failed to lower.reboxing_test.rsuses it to emit acandidatestag computed frombefore.
eytan-starkware
left a comment
There was a problem hiding this comment.
@eytan-starkware reviewed 1 file and resolved 1 discussion.
Reviewable status: all files reviewed (commit messages unreviewed), all discussions resolved (waiting on orizi).
eytan-starkware
left a comment
There was a problem hiding this comment.
@eytan-starkware reviewed 19 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on orizi).
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on orizi).

Summary
Adds a single unified golden-file test runner for lowering/optimization tests,
crates/cairo-lang-lowering/src/test_runner.rs(#[cfg(test)]), parameterized by plain Rust arguments:stage: LoweringStage— the stage thebeforebody is fetched from (db.lowered_body),before_phases: &[OptimizationPhase]— applied to producebefore,after_phases: &[OptimizationPhase]— applied to a clone to produceafter,with two variants for the special cases:
..._with_db(custom DB setup, used byearly_unsafe_panicforFlag::UnsafePanic) and..._with_extra_outputs(used byreboxingto keep itscandidatesoutput tag).14 of the 15
optimizations/*_test.rsfiles plusinline/test.rsare reduced to thin bindings passing their exact previous configuration. Net: 19 files, +382/−567.Type of change
Why is this change needed?
Every per-optimization test file duplicated the same ~40-line runner: fetch lowered body at some stage, apply a hardcoded phase slice, clone, apply the optimization, format before/after. The copies had drifted (three different diagnostics-fetch orderings, one stateful runner macro with a useless
dbfield, copy-pasted fn/module names) and adding a new optimization test meant copying the boilerplate again.What was the behavior before / after?
Test behavior is preserved: the golden-file diff across the whole migration is 2 files / 8 lines —
gas_redeposit'stest_runner_nametag rename (its runner struct became a fn) and 4 purely additive empty diagnostics tags in onereboxingcase. Zerobefore/after/candidatesbody lines changed; the other golden files are byte-identical. Case counts are unchanged (170 optimization cases + 23 inline cases).Additional context
scrub_units_test.rsdeliberately stays bespoke:scrub_unitshas noOptimizationPhasevariant (it is a hardcoded step insidelowered_body), and adding a production variant only for a test would pollute the strategy vocabulary. Documented in the runner's module doc, along with the other out-of-scope lowering tests (single-output shape, no before/after pair).const_folding_test.rs's fn is misnamedtest_match_optimizer, and three files share thescrub_unitstest_file_test!module arg.lowering_diagnostics. No existing golden case exercises these paths.🤖 Generated with Claude Code