Fix flaky cgo test failures. (#716)
Fixes flaky cgo test failures caused by duplicate printf format checks in staticcheck and go vet that use slightly different reporting formats.
This commit is contained in:
parent
1040e34da2
commit
a653032409
@ -59,8 +59,10 @@ func TestCgoOk(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCgoWithIssues(t *testing.T) {
|
||||
testshared.NewLintRunner(t).Run("--no-config", "--enable-all", getTestDataDir("cgo_with_issues")).
|
||||
testshared.NewLintRunner(t).Run("--no-config", "--disable-all", "-Egovet", getTestDataDir("cgo_with_issues")).
|
||||
ExpectHasIssue("Printf format %t has arg cs of wrong type")
|
||||
testshared.NewLintRunner(t).Run("--no-config", "--disable-all", "-Estaticcheck", getTestDataDir("cgo_with_issues")).
|
||||
ExpectHasIssue("SA5009: Printf format %t has arg #1 of wrong type")
|
||||
}
|
||||
|
||||
func TestUnsafeOk(t *testing.T) {
|
||||
|
6
test/testdata/govet.go
vendored
6
test/testdata/govet.go
vendored
@ -3,6 +3,7 @@
|
||||
package testdata
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
@ -30,3 +31,8 @@ func GovetNolintVet() error {
|
||||
func GovetNolintVetShadow() error {
|
||||
return &os.PathError{"first", "path", os.ErrNotExist} //nolint:vetshadow
|
||||
}
|
||||
|
||||
func GovetPrintf() {
|
||||
x := "dummy"
|
||||
fmt.Printf("%d", x) // ERROR "printf: Printf format %d has arg x of wrong type string"
|
||||
}
|
||||
|
6
test/testdata/staticcheck.go
vendored
6
test/testdata/staticcheck.go
vendored
@ -2,6 +2,7 @@
|
||||
package testdata
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
@ -23,3 +24,8 @@ func StaticcheckNolintMegacheck() {
|
||||
func StaticcheckDeprecated() {
|
||||
_ = runtime.CPUProfile() // ERROR "SA1019: runtime.CPUProfile is deprecated"
|
||||
}
|
||||
|
||||
func StaticcheckPrintf() {
|
||||
x := "dummy"
|
||||
fmt.Printf("%d", x) // ERROR "SA5009: Printf format %d has arg #1 of wrong type"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user