[GODRIVER-2784] Re-enable "paralleltest" linter Created: 29/Mar/23  Updated: 31/Mar/23  Resolved: 29/Mar/23

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Unknown
Reporter: Matt Dale Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to GODRIVER-2782 Fix "revive" v1.3.1 linter failures Closed
Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

The "paralleltest" linter currently panics with:

ERRO [runner] Panic: paralleltest: package "primitive" (isInitialPkg: true, needAnalyzeSource: true): runtime error: index out of range [0] with length 0: goroutine 8059 [running]:
runtime/debug.Stack()
        /usr/local/go/src/runtime/debug/stack.go:24 +0x64
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1()
        /go/pkg/mod/github.com/golangci/golangci-lint@v1.52.2/pkg/golinters/goanalysis/runner_action.go:109 +0x22c
panic({0x101e2df20, 0x1401713b998})
        /usr/local/go/src/runtime/panic.go:884 +0x1f4
github.com/kunwardeep/paralleltest/pkg/paralleltest.isTestFunction(0x101e9f700?)
        /go/pkg/mod/github.com/kunwardeep/paralleltest@v1.0.6/pkg/paralleltest/paralleltest.go:252 +0x1a8
github.com/kunwardeep/paralleltest/pkg/paralleltest.run.func1({0x101ea21b0?, 0x1401576d6b0?})
        /go/pkg/mod/github.com/kunwardeep/paralleltest@v1.0.6/pkg/paralleltest/paralleltest.go:58 +0xc4
golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder(0x1400782fcc8, {0x14001805cb8?, 0x1?, 0x1?}, 0x1400782fce0)
        /go/pkg/mod/golang.org/x/tools@v0.7.0/go/ast/inspector/inspector.go:81 +0x9c
github.com/kunwardeep/paralleltest/pkg/paralleltest.run(0x14019617b30)
        /go/pkg/mod/github.com/kunwardeep/paralleltest@v1.0.6/pkg/paralleltest/paralleltest.go:47 +0xf8
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0x1400333f050)
        /go/pkg/mod/github.com/golangci/golangci-lint@v1.52.2/pkg/golinters/goanalysis/runner_action.go:195 +0x94c
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
        /go/pkg/mod/github.com/golangci/golangci-lint@v1.52.2/pkg/golinters/goanalysis/runner_action.go:113 +0x20
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0x140003bb360, {0x101a059ff, 0xc}, 0x140021f6730)
        /go/pkg/mod/github.com/golangci/golangci-lint@v1.52.2/pkg/timeutils/stopwatch.go:111 +0x44
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0x1013f7720?)
        /go/pkg/mod/github.com/golangci/golangci-lint@v1.52.2/pkg/golinters/goanalysis/runner_action.go:112 +0x74
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0x1400333f050)
        /go/pkg/mod/github.com/golangci/golangci-lint@v1.52.2/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0xb0
created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze
        /go/pkg/mod/github.com/golangci/golangci-lint@v1.52.2/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x17c 
WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: paralleltest: package "primitive" (isInitialPkg: true, needAnalyzeSource: true): runtime error: index out of range [0] with length 0 
ERRO Running error: 1 error occurred:
        * can't run linter goanalysis_metalinter: goanalysis_metalinter: paralleltest: package "primitive" (isInitialPkg: true, needAnalyzeSource: true): runtime error: index out of range [0] with length 0

Definition of done:

  • Re-enable the "paralleltest" linter once the panic is resolved, either by updating golangci-lint or by fixing something in the Go Driver config or repo.


 Comments   
Comment by Matt Dale [ 29/Mar/23 ]

Turns out this was a problem with using tests with no named parameters.

For example, this works fine:

func TestBlah(t *testing.T) {
    // ...
}

But this causes paralleltest to panic (but is still valid Go):

func TestBlah(*testing.T) {
    // ...
}

That's technically a bug in paralleltest, but for now we fix it by using:

func TestBlah(_ *testing.T) {
    // ...
}

Edit: There's actually a PR to fix the bug described above: https://github.com/kunwardeep/paralleltest/pull/27

Generated at Thu Feb 08 08:39:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.