gotest.tools icon indicating copy to clipboard operation
gotest.tools copied to clipboard

assert/cmd/gty-migrate-from-testify: fix TestRun by adding "go get" commands

Open dolmen opened this issue 2 years ago • 6 comments

The test TestRun of the gty-migrate-from-testify tool apparently needs to have the original packages available to run. So let's install them ("go get" in GOPATH mode, in a temporary directory) before running the migration test.

Here are example of the test failures that this patch fixes:

  • https://app.circleci.com/pipelines/github/gotestyourself/gotest.tools/303/workflows/0a211869-a6ad-4bfb-83ff-77322b76edff/jobs/3406?invite=true#step-108-34
  • https://app.circleci.com/pipelines/github/gotestyourself/gotest.tools/305/workflows/faa51546-d296-4ea3-ae27-ea55f9fb10f1/jobs/3414?invite=true#step-108-34
  • https://app.circleci.com/pipelines/github/gotestyourself/gotest.tools/306/workflows/3771fe06-2f47-4f1a-a055-f8dbad25f720/jobs/3423?invite=true#step-108-34
  • https://app.circleci.com/pipelines/github/gotestyourself/gotest.tools/307/workflows/a92c08a1-cc13-40d9-abf9-440b01eb803f/jobs/3427?invite=true#step-108-34

dolmen avatar Jun 12 '23 15:06 dolmen

Unfortunately I do not get the same failure as https://app.circleci.com/pipelines/github/gotestyourself/gotest.tools/308/workflows/b1924e3f-5a1b-4cc4-967a-566c13157643/jobs/3432?invite=true#step-108-38 when I run the test on my machine (go 1.20):

$ go test -run TestRun -v                                          
=== RUN   TestRun
    main_test.go:16: go get github.com/go-check/check
    main_test.go:16: go get github.com/stretchr/testify/assert
    main_test.go:16: go get github.com/stretchr/testify/require
-: /var/folders/7b/5rfj3bgs3tj34c6f2jy8h39w0000gn/T/test-run-2939663157/src/example.com/example/some_test.go:138:1: wrong signature for TestWithChecker, must be: func TestWithChecker(t *testing.T)
assert.NotContains(t, []bool{}, true) at ../../../../../../../../var/folders/7b/5rfj3bgs3tj34c6f2jy8h39w0000gn/T/test-run-2939663157/src/example.com/example/some_test.go:56: skipping unsupported assertion
--- PASS: TestRun (16.32s)
PASS
ok  	gotest.tools/v3/assert/cmd/gty-migrate-from-testify	16.556s

dolmen avatar Jun 12 '23 15:06 dolmen

I can reproduce the CI failure with:

$ ( cd assert/cmd/gty-migrate-from-testify/testdata/full && export GO111MODULE=off && go get github.com/stretchr/testify/assert && go get gopkg.in/check.v1 && go test )

dolmen avatar Jun 12 '23 16:06 dolmen

I finally had to drop the func TestWithChecker(c *check.C) in testdata/full/some_test.go. See fcde373fd36f2df6d120657d343b9eedbf15c69b.

dolmen avatar Jun 12 '23 17:06 dolmen

Everything fixed. Ready for review.

dolmen avatar Jun 12 '23 17:06 dolmen

ping @dnephin

dolmen avatar Jun 26 '23 08:06 dolmen

Thanks for working on this! I tried the separate module in #268. I don't understand why only go1.19 is failing. I don't see anything different about that config. It should be using module mode as well. I'll keep debugging.

dnephin avatar Jun 30 '23 01:06 dnephin