mardi 25 août 2020

Why `go test ./...` run tests including third-party dependency modules?

I set up GitHub CI for a go project. In test steps, I run go test ./.... However, this command run the tests not only in project but also in third-party dependency modules which is unexpected. What's more, tests in a module(pkg/errors) even failed that cause the CI failed too.

How could I only run my project tests? I'm a go beigner, thank for your helps!

Here are the project GitHub action CI configs:

name: Build and test Go
on: [ push, pull_request ]
jobs:
  test:
    strategy:
      matrix:
        go-version: [ 1.15.x ]
        os: [ ubuntu-latest ]
        mongodb-version: [4.2]
    runs-on: $
    steps:
      - name: setup env
        shell: bash
        run: |
          echo "::set-env name=GOPATH::$/go"
          echo "::add-path::$/go/bin"
      - name: Install Go
        uses: actions/setup-go@v2
        with:
          go-version: $

      - name: Start MongoDB
        uses: supercharge/mongodb-github-action@1.3.0
        with:
          mongodb-version: $

      - name: Checkout code
        uses: actions/checkout@v2

      - name: Build
        env:
          GOPROXY: "https://proxy.golang.org"
        run: go build .

      - name: Test
        run: go test ./...

And the GitHub action failure log:

ok      github.com/klauspost/compress/zstd  30.515s
ok      github.com/klauspost/compress/zstd/internal/xxhash  0.016s
--- FAIL: TestFormatNew (0.00s)
    format_test.go:38: test 3: line 3: fmt.Sprintf("%+v", err):
         got: "error\ngithub.com/pkg/errors.TestFormatNew\n\t/home/runner/work/coinsmart-api/coinsmart-api/go/pkg/mod/github.com/pkg/errors@v0.9.1/format_test.go:26\ntesting.tRunner\n\t/opt/hostedtoolcache/go/1.15.0/x64/src/testing/testing.go:1108\nruntime.goexit\n\t/opt/hostedtoolcache/go/1.15.0/x64/src/runtime/asm_amd64.s:1374"
        want: "error\ngithub.com/pkg/errors.TestFormatNew\n\t.+/github.com/pkg/errors/format_test.go:26"
--- FAIL: TestFormatErrorf (0.00s)
    format_test.go:64: test 3: line 3: fmt.Sprintf("%+v", err):
         got: "error\ngithub.com/pkg/errors.TestFormatErrorf\n\t/home/runner/work/coinsmart-api/coinsmart-api/go/pkg/mod/github.com/pkg/errors@v0.9.1/format_test.go:56\ntesting.tRunner\n\t/opt/hostedtoolcache/go/1.15.0/x64/src/testing/testing.go:1108\nruntime.goexit\n\t/opt/hostedtoolcache/go/1.15.0/x64/src/runtime/asm_amd64.s:1374"
        want: "error\ngithub.com/pkg/errors.TestFormatErrorf\n\t.+/github.com/pkg/errors/format_test.go:56"
--- FAIL: TestFormatWrap (0.00s)

Aucun commentaire:

Enregistrer un commentaire