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:
Trevor Pounds 2019-09-20 12:05:01 -04:00 committed by Isaev Denis
parent 1040e34da2
commit a653032409
3 changed files with 15 additions and 1 deletions

View File

@ -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) {

View File

@ -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"
}

View File

@ -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"
}