3 ms·
I went to an awful lot of trouble to apply roughly the same technique to test some code generation code [0]. Required pulling in a random dependency and hackin
by couchand 6y ago
I went to an awful lot of trouble to apply roughly the same technique to test some code generation code [0]. Required pulling in a random dependency and hacking around for a while to make the output look right. Your solution is much slicker!
[0]: https://github.com/couchand/wayfinder/blob/1dc58a1130bc179413018e3a9c374da52b4e9881/wayfinder-tests/build.rs https://github.com/couchand/wayfinder/blob/1dc58a1130bc17941...
- chrismorgan 6y agoWhat you ended up with has two major advantages: ① it integrates with the Cargo test harness, so that Rust developers’ expectations will be met; and ② it does it in one compiler invocation. The test harness I describe would be quite slow for your sort of situation. I’m not completely sold on using a separate crate and build.rs how you have, but it looks like it’ll yield a good usable result. A couple of related things you might be interested in: compiletest_rs, trybuild.