Skip to content

Commit

Permalink
feat(deps)!: switch to Uber's maintained fork of gomock
Browse files Browse the repository at this point in the history
  • Loading branch information
jimeh committed Oct 13, 2023
1 parent 58c73d9 commit f2b90ba
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 45 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $(eval $(call tool,gofumpt,mvdan.cc/gofumpt@latest))
$(eval $(call tool,goimports,golang.org/x/tools/cmd/goimports@latest))
$(eval $(call tool,golangci-lint,github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54))
$(eval $(call tool,gomod,github.com/Helcaraxan/gomod@latest))
$(eval $(call tool,mockgen,github.com/golang/mock/mockgen@v1.6.0))
$(eval $(call tool,mockgen,go.uber.org/mock/mockgen@v0.3.0))

.PHONY: tools
tools: $(TOOLS)
Expand Down Expand Up @@ -92,6 +92,12 @@ bench:
.PHONY: generate
generate: $(TOOLDIR)/mockgen
go generate ./...
@find . -type f -name '*.go' | while read -r file; do \
cat "$$file" | go run scripts/mockgen_fix.go > "$$file.tmp"; \
mv "$$file.tmp" "$$file"; \
done



.PHONY: check-generate
check-generate: $(TOOLDIR)/mockgen
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module github.com/krystal/go-runner
go 1.18

require (
github.com/golang/mock v1.6.0
github.com/romdo/gomockctx v0.1.0
github.com/romdo/gomockctx v0.2.0
github.com/stretchr/testify v1.7.1
go.uber.org/mock v0.3.0
)

require (
Expand Down
32 changes: 4 additions & 28 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,39 +1,15 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/romdo/gomockctx v0.1.0 h1:pkizAatykBP0gmtQs9wMGYPBUlSK0dmLl+O3N9aWd7k=
github.com/romdo/gomockctx v0.1.0/go.mod h1:t1xklNc2fVZ7d9S7WOZuXM1ytnPh6nXn5WyZK7XskVs=
github.com/romdo/gomockctx v0.2.0 h1:yNT6hfBVMDemaqQlbhvUV/kNYawP93vPECWVpTU3l84=
github.com/romdo/gomockctx v0.2.0/go.mod h1:Mr+f54zpuXT1rEUxpwF6OfkpY/idEbkBk3wkmRJcPJ8=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
go.uber.org/mock v0.3.0 h1:3mUxI1No2/60yUYax92Pt8eNOEecx2D3lcXZh2NEZJo=
go.uber.org/mock v0.3.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
20 changes: 10 additions & 10 deletions mock/runner.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"os/exec"
)

//go:generate go run github.com/golang/mock/mockgen@v1.6.0 -source=$GOFILE -destination=mock/${GOFILE}
//go:generate mockgen -source=$GOFILE -destination=mock/${GOFILE}

// Runner is the interface that all runner structs implements. It makes it easy
// to replace the underlying command runner with a mock for testing, or a
Expand Down
25 changes: 25 additions & 0 deletions scripts/mockgen_fix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"fmt"
"io"
"os"
"regexp"
)

var re = regexp.MustCompile(
`(?ms)^(\/\/ Code generated by MockGen.+?Source: .+?)$` +
`.*?` +
`^(// Package mock_.+?)$`,
)

func main() {
b, err := io.ReadAll(os.Stdin)
if err != nil {
return
}

result := re.ReplaceAllString(string(b), "$1\n//\n$2")

fmt.Print(result)
}
2 changes: 1 addition & 1 deletion ssh_cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"io"
"testing"

"github.com/golang/mock/gomock"
mock_runner "github.com/krystal/go-runner/mock"
"github.com/romdo/gomockctx"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
)

func TestSSHCLI_Run(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion sudo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"io"
"testing"

"github.com/golang/mock/gomock"
mock_runner "github.com/krystal/go-runner/mock"
"github.com/romdo/gomockctx"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
)

func TestSudo_Run(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion testing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"io"
"testing"

"github.com/golang/mock/gomock"
mock_runner "github.com/krystal/go-runner/mock"
"github.com/romdo/gomockctx"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
)

type fakeTestingT struct {
Expand Down

0 comments on commit f2b90ba

Please sign in to comment.