File tree Expand file tree Collapse file tree 2 files changed +23
-12
lines changed
.claude/skills/testing-hashql Expand file tree Collapse file tree 2 files changed +23
-12
lines changed Original file line number Diff line number Diff line change @@ -180,6 +180,12 @@ For testing MIR transformation and analysis passes directly with programmaticall
180180- Edge cases requiring specific MIR structures hard to produce from source
181181- Benchmarking pass performance
182182
183+ ** Key features:**
184+
185+ - Transform passes return ` Changed ` enum (` Yes ` , ` No ` , ` Unknown ` ) to indicate modifications
186+ - Test harness captures and includes ` Changed ` value in snapshots for verification
187+ - Snapshot format: before MIR → ` Changed: Yes/No/Unknown ` separator → after MIR
188+
183189** Quick Example:**
184190
185191``` rust
@@ -201,10 +207,10 @@ builder
201207let body = builder . finish (0 , TypeBuilder :: synthetic (& env ). integer ());
202208```
203209
204- 📖 ** Full Guide:** [ resources /mir-builder-guide.md] ( resources /mir-builder-guide.md)
210+ 📖 ** Full Guide:** [ references /mir-builder-guide.md] ( references /mir-builder-guide.md)
205211
206212## References
207213
208- - [ compiletest Guide] ( resources /compiletest-guide.md) - Detailed UI test documentation
209- - [ Testing Strategies] ( resources /testing-strategies.md) - Choosing the right approach
210- - [ MIR Builder Guide] ( resources /mir-builder-guide.md) - Programmatic MIR construction for tests
214+ - [ compiletest Guide] ( references /compiletest-guide.md) - Detailed UI test documentation
215+ - [ Testing Strategies] ( references /testing-strategies.md) - Choosing the right approach
216+ - [ MIR Builder Guide] ( references /mir-builder-guide.md) - Programmatic MIR construction for tests
Original file line number Diff line number Diff line change @@ -228,10 +228,11 @@ builder.build_block(bb_merge).ret(x); // x receives value from param
228228
229229## Test Harness Pattern
230230
231- Standard pattern used across transform pass tests:
231+ Standard pattern used across transform pass tests. The harness captures and displays
232+ the ` Changed ` return value to verify pass behavior:
232233
233234``` rust
234- use std :: path :: PathBuf ;
235+ use std :: { io :: Write as _, path :: PathBuf } ;
235236use bstr :: ByteVec as _;
236237use hashql_core :: {
237238 pretty :: Formatter ,
@@ -274,12 +275,16 @@ fn assert_pass<'heap>(
274275 . format (DefIdSlice :: from_raw (& bodies ), & [])
275276 . expect (" should be able to write bodies" );
276277
277- text_format
278- . writer
279- . extend (b " \ n\ n ------------------------------------\ n\ n" );
280-
281- // Run the pass
282- YourPass :: new (). run (context , & mut bodies [0 ]);
278+ // Run the pass and capture change status
279+ let changed = YourPass :: new (). run (context , & mut bodies [0 ]);
280+
281+ // Include Changed value in snapshot for verification
282+ write! (
283+ text_format . writer,
284+ " \ n\ n {:=^50}\ n\ n" ,
285+ format! (" Changed: {changed:?} " )
286+ )
287+ . expect (" infallible" );
283288
284289 // Format after
285290 text_format
You can’t perform that action at this time.
0 commit comments