-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
migrate test-infra to testify for br/pkg
#27178
Comments
|
Some analyses 🤔 GeneralThe most simple way for adapting go check is to use the Some of "stateless" tests, which:
...can be refactored as plain go test cases. SuitesThe lifecycle methods of
CheckersThe following BytesEquals // can be replaced with require.Equal
DeepEquals // same as above
Equals // same as above
// Reason see https://github.com/stretchr/testify/blob/acba37e5db06f0093b465a7d47822bf13644b66c/assert/assertions.go#L58-L76
ErrorMatches // require.EqualError
FieldEquals // custom checker, using `zapcore.Field.Equals`
FitsTypeOf // maybe require.IsType
Greater // require.Greater
GreaterEqual // require.GreaterOrEqual
HasKey // ?
HasLen // require.Len
IsFalse // require.False
IsNil // require.Nil
IsTrue // require.True
Less // require.Less
LessEqual // require.LessOrEqual
Matches // require.Regexp?
Not // testify didn't support `Checker`, let alone combinators over them...
NotNil // require.NotNil
PanicMatches // maybe require.PanicsWith{Error,Object}?
RangeEquals // custom checker, checking the start key and end keys are equal.
isAbout // custom checker, checking whether two floating numbers are near enough.
jsonEquals // require.JSONEq
posEq // custom checker, checking the pos of a parser.
unblocksBetween // custom checker, checks whether a wait group done in a time interval.
versionEquals // custom checker for semvers. Some of the checkers has alternative methods in
|
@YuJuncen No. We don't do that. Please see also #26082 (comment) and this Chinese post for details. And #27747 for an example. |
@YuJuncen @feitian124 already creates a tool you may make use of to automatically migrate #26022 (comment) . However, I'd prefer just do it manually with some "global find and replace" for common pattern. If you try to do something automatically and correctly, you're always in trouble - you're now find a new, and probably huge, question to resolve, which is unnecessary to the original problem. |
Just use |
Also, it is not a 1 to 1 mapping as If you can find such one, I'm glad to update the description and create subtasks. |
br
pkgbr/pkg
pkg
The first thing I found is that these tests are all under |
br/pkg
pkgbr/pkg
@tisonkun
func TestTeardownParallel(t *testing.T) {
// This Run will not return until the parallel tests finish.
t.Run("group", func(t *testing.T) {
t.Run("Test1", parallelTest1)
t.Run("Test2", parallelTest2)
t.Run("Test3", parallelTest3)
})
// <tear-down code>
} Sounds good, but sometimes when setting up, some variables in the suite also have been set.
func TestTeardownParallel(t *testing.T) {
suite := setupSuite()
t.Run("group", func(t *testing.T) {
t.Run("Test1", suite.parallelTest1)
t.Run("Test2", suite.parallelTest2)
t.Run("Test3", suite.parallelTest3)
})
// <tear-down code>
} For automating: Maybe refactor tools like |
@YuJuncen You're welcome to try on a subtask. And if it works well, I hope you can write it down to teach others how to achieve it. |
Closed as all subtasks done. |
br/pkg/backup
#28164br/pkg/cdclog
#28165br/pkg/checksum
#28166br/pkg/conn
#28167br/pkg/gluetikv
#28168br/pkg/kv
#28169br/pkg/lightning
#28170br/pkg/logutil
#28171br/pkg/membuf
#28172br/pkg/metautil
#28173br/pkg/mock
#28174br/pkg/pdutil
#28175br/pkg/redact
#28176br/pkg/restore
#28177br/pkg/rtree
#28178br/pkg/storage
#28179br/pkg/summary
#28180br/pkg/task
#28181br/pkg/trace
#28182br/pkg/utils
#28183br/pkg/version
#28184The text was updated successfully, but these errors were encountered: