assert: improve godoc and failure messages #229
Merged
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.
Primarily this improve the godoc for the assert package in two ways:
t.FailNow
and therefore should only be called from the main test goroutine.Check
should be used from all other goroutines.Also makes some minor improvements to failures messages:
assert.Assert
when the argument is aast.Ident
boolean, or a binary expression (==
,>
, etc).assert.ErrorIs
when the type is a stdlib type (*errors.errorString
, or*fmt.wrapError
, which come fromerrors.New
, orfmt.Errorf
). These types are not going to be relevant, so omitting them helps keep the failure message clear.I'm going to try and preview the html rendered godoc before tagging a new release, to make sure it renders the way I expect.
Also adds a deprecation notice to
env.Patch
sincet.SetEnv
takes care of that now.Note: this PR breaks compatiblity with Go1.12 by removing the go1.13 build tag that was guarding calls to
errors.Is
.gotest.tools/v3@v3.1.0
will be the last version that will work with Go 1.12.