PeekPokeAPI: include source location on failed expect() calls. (backport #4144) #4149
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:
SourceInfo
collection and reporting in the exception.testableData.expect
(withexpected
,encode
andbuildMessage
arguments) to be called by a test user directly? If not, I have a slight preference for making thesourceInfo
argument 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.getErrorLineInFile
over toExceptionHelpers
and mark itprivate[chisel3]
so it doesn't become a new public API to maintain. We have to takesourceRoots
as an argument.expect()
(noBuilder
context, etc., so I'm not sure how to get at theChiselOptions
for 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.expect
calls now record source location and report it in theFailedExpectationException
on failure.Reviewer Checklist (only modified by reviewer)
3.6.x
,5.x
, or6.x
depending 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).