Add precise_output argument to test optimize.#6111
Conversation
Also allow optimise tests to be updated by `CRANELIFT_TEST_BLESS=1`
|
This is neat! It's clearly handy to be able to regenerate test expectations like this. I don't know for sure that precise output tests are a good idea for optimizations though. Writing assertions about only the specific aspects we're trying to test makes the tests more resilient to unrelated changes in the optimizer. |
Could we do a script to automatically insert the correct |
Yes, I think we want to retain this property: many of the tests are checking just "this one value becomes X" rather than freezing the entire output. There is still some unnecessary capture of implementation details (e.g. the value number in the output exposes how many rewrites we went through) but less coupling is better here. It would be nice to try to find ways to automate updates though! |
|
Yeah for tests that are asserting one particular peephole applied, it is nice to not have the full precise output. There are certainly other tests that are written in a less targeted way, and could be migrated to precise output tests on a case-by-case basis. Because of this, it would be nice to support, even if we don't blanket enable it for every |
jameysharp
left a comment
There was a problem hiding this comment.
Given that Nick thinks we'll find uses for this, let's go ahead and merge it. I've reviewed it and it's good, but I do have one thing I want changed before merge:
Let's share check_precise_output and update_test between all subtest modes that have a precise-output option. I think it makes sense to put these functions in cranelift/filetests/src/subtest.rs since they only rely on Context. Optionally, they could be methods on Context.
If I'm not mistaken, this copy of update_test is identical to the one in test_compile.rs, and this copy of check_precise_output is almost identical except for requiring the caller to provide a slice of strings. The latter is easily unified by moving the definition of actual to run in test_compile.rs.
Looking at this diff, there are several things I'd like to change in these functions, but they're all things that were pre-existing in test_compile.rs, so let's not change them in this PR.
9547fa0 to
b8ab7a9
Compare
b8ab7a9 to
585cb1f
Compare
jameysharp
left a comment
There was a problem hiding this comment.
Looks good to me, thank you!
Allow
test optimizetests to take theprecise-outputargument, and to be updated byCRANELIFT_TEST_BLESS, similar totest compile