Repository navigation
feat: add concrete playback support for multiple failing harnesses - #1558
Conversation
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| // kani-flags: --harness harness --enable-unstable --concrete-playback=Print | ||
| // kani-flags: --enable-unstable --concrete-playback=Print |
There was a problem hiding this comment.
A little off-topic, but... Why are we writing --concrete-playback=Print in our tests? The options mentioned in the docs are [print|inplace], should we make this case-sensitive?
There was a problem hiding this comment.
Done. I changed it to --concrete-playback=print.
I think we should keep it as case-insensitive since our kani-driver arguments seem to follow a lower-case standard while the Rust enum conventions use upper case.
There was a problem hiding this comment.
I believe our flags all follow kebab-case, but unfortunately the arguments don't. We turned case-insensitive to go around this, but ideally we should configure everything to be consistent. I couldn't find any easy fix with structopts though and we would need to migrate to using clap directly.
celinval
left a comment
There was a problem hiding this comment.
I just have one comment about using slice sort instead of generating new harness vector. I think it's cleaner.
| /// appearing harnesses get processed earlier. | ||
| /// This is necessary for the concrete playback feature (with in-place unit test modification) | ||
| /// because it guarantees that injected unit tests will not change the location of to-be-processed harnesses. | ||
| pub fn sort_harnesses(harnesses: &[HarnessMetadata]) -> Vec<HarnessMetadata> { |
There was a problem hiding this comment.
There was a problem hiding this comment.
Originally, I called sort directly on the slice (I think this is what you are recommending). Then, @adpaco-aws commented that I should return a new vector, so I changed the code. These two recommendation seem to conflict. Which one would you like me to do?
There was a problem hiding this comment.
Oh, sorry, I didn't see that comment.
You can leave it as is.
| /// appearing harnesses get processed earlier. | ||
| /// This is necessary for the concrete playback feature (with in-place unit test modification) | ||
| /// because it guarantees that injected unit tests will not change the location of to-be-processed harnesses. | ||
| pub fn sort_harnesses(harnesses: &[HarnessMetadata]) -> Vec<HarnessMetadata> { |
There was a problem hiding this comment.
nit: sort_by_location or something like that since correctness depend on what we are sorting it by.
There was a problem hiding this comment.
Done. Updated func name.
Description of changes:
Previously, the concrete playback feature did not work for in-place modification of multiple unit tests for failing harnesses. We had mitigated this issue by requiring the
--harnessargument. In this PR, we remove the restriction by sorting the harnesses according to greater start line gets computed earlier. This makes the source file updates not interfere with the line numbers computed before any updates happened.Resolved issues:
Resolves #1506.
Call-outs:
I needed to compare the line numbers as actual numbers, not as strings (the way they were before). I figured I might as well just convert their types to numbers in the first place.
Testing:
There is a multiple harness test that checks that later harnesses are generated earlier.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.