From d2beda1f0016a11b0b0a364eff06a153eb4a448a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 25 Feb 2024 23:12:04 +0000 Subject: [PATCH] switch frankban/quicktest for go-quicktest/qt The latter is newer and uses generics. --- bench_test.go | 26 +++++++++++++------------- go.mod | 2 +- go.sum | 5 ++--- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/bench_test.go b/bench_test.go index 7a7474a..f8e5f96 100644 --- a/bench_test.go +++ b/bench_test.go @@ -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 } diff --git a/go.mod b/go.mod index ff8ddd7..96cae44 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 781706f..3fb5ae3 100644 --- a/go.sum +++ b/go.sum @@ -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=