switch frankban/quicktest for go-quicktest/qt

The latter is newer and uses generics.
pull/840/head
Daniel Martí 2 months ago committed by pagran
parent f09db67c89
commit d2beda1f00

@ -16,7 +16,7 @@ import (
"testing"
"time"
qt "github.com/frankban/quicktest"
"github.com/go-quicktest/qt"
)
//go:embed testdata/bench/main.go
@ -57,11 +57,11 @@ func BenchmarkBuild(b *testing.B) {
outputBin := filepath.Join(tdir, "output")
sourceDir := filepath.Join(tdir, "src")
qt.Assert(b, os.Mkdir(sourceDir, 0o777), qt.IsNil)
qt.Assert(b, qt.IsNil(os.Mkdir(sourceDir, 0o777)))
writeSourceFile := func(name string, content []byte) {
err := os.WriteFile(filepath.Join(sourceDir, name), content, 0o666)
qt.Assert(b, err, qt.IsNil)
qt.Assert(b, qt.IsNil(err))
}
writeSourceFile("go.mod", []byte("module test/main"))
writeSourceFile("main.go", benchSourceMain)
@ -74,11 +74,11 @@ func BenchmarkBuild(b *testing.B) {
// First we do a fresh build, using empty cache directories,
// and the second does an incremental rebuild reusing the same cache directories.
goCache := filepath.Join(tdir, "go-cache")
qt.Assert(b, os.RemoveAll(goCache), qt.IsNil)
qt.Assert(b, os.Mkdir(goCache, 0o777), qt.IsNil)
qt.Assert(b, qt.IsNil(os.RemoveAll(goCache)))
qt.Assert(b, qt.IsNil(os.Mkdir(goCache, 0o777)))
garbleCache := filepath.Join(tdir, "garble-cache")
qt.Assert(b, os.RemoveAll(garbleCache), qt.IsNil)
qt.Assert(b, os.Mkdir(garbleCache, 0o777), qt.IsNil)
qt.Assert(b, qt.IsNil(os.RemoveAll(garbleCache)))
qt.Assert(b, qt.IsNil(os.Mkdir(garbleCache, 0o777)))
env := append(os.Environ(),
"RUN_GARBLE_MAIN=true",
"GOCACHE="+goCache,
@ -106,25 +106,25 @@ func BenchmarkBuild(b *testing.B) {
cachedTime += time.Since(cachedStart).Nanoseconds()
}
qt.Assert(b, err, qt.IsNil, qt.Commentf("output: %s", out))
qt.Assert(b, qt.IsNil(err), qt.Commentf("output: %s", out))
if !cached {
// Ensure that we built all packages, as expected.
qt.Assert(b, rxBuiltRuntime.Match(out), qt.IsTrue)
qt.Assert(b, qt.IsTrue(rxBuiltRuntime.Match(out)))
} else {
// Ensure that we only rebuilt the main package, as expected.
qt.Assert(b, rxBuiltRuntime.Match(out), qt.IsFalse)
qt.Assert(b, qt.IsFalse(rxBuiltRuntime.Match(out)))
}
qt.Assert(b, rxBuiltMain.Match(out), qt.IsTrue)
qt.Assert(b, qt.IsTrue(rxBuiltMain.Match(out)))
matches := rxGarbleAllocs.FindAllSubmatch(out, -1)
if !cached {
// The non-cached version should have at least a handful of
// sub-processes; catch if our logic breaks.
qt.Assert(b, len(matches) > 5, qt.IsTrue)
qt.Assert(b, qt.IsTrue(len(matches) > 5))
}
for _, match := range matches {
allocs, err := strconv.ParseInt(string(match[1]), 10, 64)
qt.Assert(b, err, qt.IsNil)
qt.Assert(b, qt.IsNil(err))
memoryAllocs += allocs
}

@ -4,7 +4,7 @@ go 1.22
require (
github.com/bluekeyes/go-gitdiff v0.7.1
github.com/frankban/quicktest v1.14.6
github.com/go-quicktest/qt v1.101.0
github.com/google/go-cmp v0.6.0
github.com/rogpeppe/go-internal v1.12.0
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3

@ -1,9 +1,8 @@
github.com/bluekeyes/go-gitdiff v0.7.1 h1:graP4ElLRshr8ecu0UtqfNTCHrtSyZd3DABQm/DWesQ=
github.com/bluekeyes/go-gitdiff v0.7.1/go.mod h1:QpfYYO1E0fTVHVZAZKiRjtSGY9823iCdvGXBcEzHGbM=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI=
github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=

Loading…
Cancel
Save