Test-case reducers are underappreciated debugging tools
ltratt
108 points
13 comments
June 09, 2026
Related Discussions
Found 5 related stories in 101.5ms across 10,002 title embeddings via pgvector HNSW
- With Claude: Less Coding, More Testing ingve · 22 pts · May 31, 2026 · 50% similar
- Refactoring Untested Code kakerane · 11 pts · April 06, 2026 · 49% similar
- Show HN: Record manual QA flows, get E2E test code that fits your repo mihau · 14 pts · March 24, 2026 · 48% similar
- Retrofitting JIT Compilers into C Interpreters ltratt · 65 pts · April 15, 2026 · 45% similar
- Should QA exist? PretzelFisch · 119 pts · March 27, 2026 · 43% similar
Discussion Highlights (7 comments)
sigbottle
I've only ever known about these through compilers, very cool. On one project, through a variety of circumstances, dead code elimination was straight up not working, but we wanted to show the theoretical improvement of some approach - but we couldn't figure out why at the moment (we did spend a whole week chasing down the root cause after - maybe worth in hindsight...). We were doing it by hand at one point, but someone suggested using CReduce for shrinking the code. Definitely was an interesting test-iterate loop...
mrkeen
> To make things even worse, the community that has most thoroughly embraced them are compiler authors, who many programmers think of as being an impossibly skilled elite The article's approach seems super ad-hoc, leaving you to have to think hard, do all the work, and make all the mistakes. If you were to go down the other path, you might try dividing and conquering the problem. An arbitrary Pair<A,B> is trivially constructed from an arbitrary A and an arbitrary B. So if you can generate a string, and a number, you could generate a User full of number and string fields. If your generate function accepts a number describing how complex a string to make, then you can also choose how complicated to make your User. That's all shrinking needs to be. Repeatedly trying smaller Ns while the problem still happens (the problem being one of your unit tests - not an additional "interestingness" test you need to write.) You'll probably way more likely to hit boundary cases by using the structure of the input and making interesting variations that way, rather than hoping you can permute the right bytes from the CLI.
skybrian
Property-based testing frameworks will often do test case reduction as well (called shrinking).
hungryhobbit
I read the first part of this article, then gave up and Googled "Test-case Reducers". I'm not sure if that's an article failure (that I didn't want to read a whole ton of text and C code details), or a success (as it got me interested in the topic). I guess both?
nnunley
I have a similar tool to shrink ray, called [bonsai]( https://github.com/nnunley/bonsai ). I designed it to allow me to try to inline and reduce code for both simplifying single file examples, as well working across multiple files. It uses Tree-Sitter for syntax awareness, and the [Perses algorithm]( https://doi.org/10.1109/ICSE.2018.00046 ) as the methodology for simplification. I'd love to get some feedback if anyone's interested.
bobbiechen
Nice share. Increasingly I am thinking about ways to improve verification ("interestingness tests"), ever since reading https://www.jasonwei.net/blog/asymmetry-of-verification-and-...
WalterBright
Dustmite is a fantastic tool for finding a bug in your program, by removing parts of the code until the result is the bug. https://dlang.org/blog/2020/04/13/dustmite-the-general-purpo... Created by Vladimir Panteleev