mirror of
https://github.com/golang/go
synced 2024-11-18 16:14:46 -07:00
go/packages/packagestest: adds a benchmark version of TestAll
This is needed because testing.TB does not have a "Run" method for sub tests, and the signature of the function it takes needs to match the testing parameter. Change-Id: I9201dd75891ed1bda300a4247fe7eac1e25bd30d Reviewed-on: https://go-review.googlesource.com/c/150857 Run-TryBot: Ian Cottrell <iancottrell@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
ff0519d4cf
commit
72292f0c83
@ -94,6 +94,19 @@ func TestAll(t *testing.T, f func(*testing.T, Exporter)) {
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkAll invokes the testing function once for each exporter registered in
|
||||
// the All global.
|
||||
// Each exporter will be run as a sub-test named after the exporter being used.
|
||||
func BenchmarkAll(b *testing.B, f func(*testing.B, Exporter)) {
|
||||
b.Helper()
|
||||
for _, e := range All {
|
||||
b.Run(e.Name(), func(b *testing.B) {
|
||||
b.Helper()
|
||||
f(b, e)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Export is called to write out a test directory from within a test function.
|
||||
// It takes the exporter and the build system agnostic module descriptions, and
|
||||
// uses them to build a temporary directory.
|
||||
|
Loading…
Reference in New Issue
Block a user