Skip to content

Commit

Permalink
swap frankban/quicktest for go-quicktest/qt
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdan committed Feb 25, 2024
1 parent 7ccdb87 commit 52739c5
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 22 deletions.
6 changes: 3 additions & 3 deletions format/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package format_test
import (
"testing"

qt "github.com/frankban/quicktest"
"github.com/go-quicktest/qt"

"mvdan.cc/gofumpt/format"
)
Expand All @@ -33,6 +33,6 @@ func f() {
}
`[1:])
got, err := format.Source(in, format.Options{})
qt.Assert(t, err, qt.IsNil)
qt.Assert(t, string(got), qt.Equals, string(want))
qt.Assert(t, qt.IsNil(err))
qt.Assert(t, qt.Equals(string(got), string(want)))
}
12 changes: 6 additions & 6 deletions format/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ import (
"strings"
"testing"

qt "github.com/frankban/quicktest"
"github.com/go-quicktest/qt"
"golang.org/x/tools/txtar"
)

func FuzzFormat(f *testing.F) {
// Initialize the corpus with the Go files from our test scripts.
paths, err := filepath.Glob(filepath.Join("..", "testdata", "script", "*.txtar"))
qt.Assert(f, err, qt.IsNil)
qt.Assert(f, paths, qt.Not(qt.HasLen), 0)
qt.Assert(f, qt.IsNil(err))
qt.Assert(f, qt.Not(qt.HasLen(paths, 0)))
for _, path := range paths {
archive, err := txtar.ParseFile(path)
qt.Assert(f, err, qt.IsNil)
qt.Assert(f, qt.IsNil(err))
for _, file := range archive.Files {
f.Logf("adding %s from %s", file.Name, path)
if strings.HasSuffix(file.Name, ".go") || strings.Contains(file.Name, ".go.") {
Expand All @@ -48,7 +48,7 @@ func FuzzFormat(f *testing.F) {
if errors.As(err, &scanner.ErrorList{}) {
return // invalid syntax from parsing
}
qt.Assert(t, err, qt.IsNil)
qt.Assert(t, qt.IsNil(err))
_ = formatted

// TODO: verify that the result is idempotent
Expand All @@ -58,7 +58,7 @@ func FuzzFormat(f *testing.F) {

// TODO: check calling format.Node directly as well

qt.Assert(t, string(orig), qt.Equals, src,
qt.Assert(t, qt.Equals(string(orig), src),
qt.Commentf("input source bytes were modified"))
})
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module mvdan.cc/gofumpt
go 1.21

require (
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/mod v0.14.0
Expand Down
5 changes: 2 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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=
Expand Down
4 changes: 2 additions & 2 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"path/filepath"
"testing"

qt "github.com/frankban/quicktest"
"github.com/go-quicktest/qt"

"github.com/rogpeppe/go-internal/gotooltest"
"github.com/rogpeppe/go-internal/testscript"
Expand Down Expand Up @@ -53,6 +53,6 @@ func TestScript(t *testing.T) {
},
}
err = gotooltest.Setup(&p)
qt.Assert(t, err, qt.IsNil)
qt.Assert(t, qt.IsNil(err))
testscript.Run(t, p)
}
14 changes: 7 additions & 7 deletions ulimit_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"strconv"
"testing"

qt "github.com/frankban/quicktest"
"github.com/go-quicktest/qt"
"golang.org/x/sys/unix"
)

Expand All @@ -37,7 +37,7 @@ func TestWithLowOpenFileLimit(t *testing.T) {

tempDir := t.TempDir()
testBinary, err := os.Executable()
qt.Assert(t, err, qt.IsNil)
qt.Assert(t, qt.IsNil(err))

const (
// Enough directories to run into the ulimit.
Expand All @@ -55,18 +55,18 @@ func TestWithLowOpenFileLimit(t *testing.T) {
dirName := fmt.Sprintf("p%03d", i)
dirPath := filepath.Join(tempDir, dirName)
err := os.MkdirAll(dirPath, 0o777)
qt.Assert(t, err, qt.IsNil)
qt.Assert(t, qt.IsNil(err))

err = os.WriteFile(filepath.Join(dirPath, "go.mod"),
[]byte(fmt.Sprintf("module %s\n\ngo 1.16", dirName)), 0o666)
qt.Assert(t, err, qt.IsNil)
qt.Assert(t, qt.IsNil(err))

for j := 0; j < numberFilesPerDir; j++ {
filePath := filepath.Join(dirPath, fmt.Sprintf("%03d.go", j))
err := os.WriteFile(filePath,
// Extra newlines so that "-l" prints all paths.
[]byte(fmt.Sprintf("package %s\n\n\n", dirName)), 0o666)
qt.Assert(t, err, qt.IsNil)
qt.Assert(t, qt.IsNil(err))
allGoFiles = append(allGoFiles, filePath)
}
}
Expand All @@ -83,8 +83,8 @@ func TestWithLowOpenFileLimit(t *testing.T) {
if err, _ := err.(*exec.ExitError); err != nil {
stderr = err.Stderr
}
qt.Assert(t, err, qt.IsNil, qt.Commentf("stderr:\n%s", stderr))
qt.Assert(t, bytes.Count(out, []byte("\n")), qt.Equals, len(allGoFiles))
qt.Assert(t, qt.IsNil(err), qt.Commentf("stderr:\n%s", stderr))
qt.Assert(t, qt.Equals(bytes.Count(out, []byte("\n")), len(allGoFiles)))
}
runGofmt(tempDir)
runGofmt(allGoFiles...)
Expand Down

0 comments on commit 52739c5

Please sign in to comment.