PeekPokeAPI: include source location on failed expect() calls. (backport #4144) - #4149
Merged
Conversation
* simulator: add SourceInfo to expect calls and report. * simulator: add test for failed expects. * simulator: attempt to extract source line. * simulator: make testableData.expect's sourceInfo parameter explicit. * simulator: add factory method for giving failed expect sourceInfo/extraContext. (cherry picked from commit 45dd82a) # Conflicts: # src/test/scala/chiselTests/simulator/SimulatorSpec.scala
Contributor
Author
|
Cherry-pick of 45dd82a has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4128. (cc @jackkoenig)
Some notes:
SourceInfocollection and reporting in the exception.testableData.expect(withexpected,encodeandbuildMessagearguments) to be called by a test user directly? If not, I have a slight preference for making thesourceInfoargument non-implicit there, and only having it implicit in the user-facing calls onSimulationData.expect()actually does anything. This isn't specific to this work.ErrorLog, and use it to embellish the exception.getErrorLineInFileover toExceptionHelpersand mark itprivate[chisel3]so it doesn't become a new public API to maintain. We have to takesourceRootsas an argument.expect()(noBuildercontext, etc., so I'm not sure how to get at theChiselOptionsfor a given module, if it's even possible), so we just use none, which defaults toSeq(new File(".")). This works fine for Chisel's own test cases and mine in my testing, but maybe there's more complicated setups out there.I'm not emotionally wed to any of this, so do feel free to suggest other ways for it to be done, or to rework it yourself if that's less overall work! (Particularly thinking of the refactor here, as it's not the cleanest.)
It does work nicely, though:
Contributor Checklist
docs/src?Type of Improvement
Desired Merge Strategy
Release Notes
SimulationData.expectcalls now record source location and report it in theFailedExpectationExceptionon failure.Reviewer Checklist (only modified by reviewer)
3.6.x,5.x, or6.xdepending on impact, API modification or big change:7.0)?Enable auto-merge (squash), clean up the commit message, and label withPlease Merge.Create a merge commit.This is an automatic backport of pull request #4144 done by [Mergify](https://mergify.com).