Skip to content

Commit b878418

Browse files
committed
SA1030: actually guard some tests behind Go 1.15
We need actual Go build tags to prevent compiling test cases with an older Go version. We also need to actually remove the offending lines of code from the more general test case. While we're here, we can also rename the test directory, 1.15 != 1.5.
1 parent da78760 commit b878418

File tree

4 files changed

+4
-12
lines changed

4 files changed

+4
-12
lines changed

staticcheck/lint_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestAll(t *testing.T) {
4343
"SA1029": {{Dir: "CheckWithValueKey"}},
4444
"SA1030": {
4545
{Dir: "CheckStrconv"},
46-
{Dir: "CheckStrconv_go15", Version: "1.15"},
46+
{Dir: "CheckStrconv_go115", Version: "1.15"},
4747
},
4848
"SA2000": {{Dir: "CheckWaitgroupAdd"}},
4949
"SA2001": {{Dir: "CheckEmptyCriticalSection"}},

staticcheck/testdata/src/CheckStrconv/CheckStrconv.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ package pkg
33
import "strconv"
44

55
func fn() {
6-
strconv.ParseComplex("", 32) // want `'bitSize' argument is invalid, must be either 64 or 128`
7-
strconv.ParseComplex("", 64)
8-
strconv.ParseComplex("", 128)
9-
strconv.ParseComplex("", 256) // want `'bitSize' argument is invalid, must be either 64 or 128`
10-
116
strconv.ParseFloat("", 16) // want `'bitSize' argument is invalid, must be either 32 or 64`
127
strconv.ParseFloat("", 32)
138
strconv.ParseFloat("", 64)
@@ -37,12 +32,6 @@ func fn() {
3732
strconv.ParseUint("", 36, 0)
3833
strconv.ParseUint("", 37, 0) // want `'base' must not be larger than 36`
3934

40-
strconv.FormatComplex(0, 'e', 0, 32) // want `'bitSize' argument is invalid, must be either 64 or 128`
41-
strconv.FormatComplex(0, 'e', 0, 64)
42-
strconv.FormatComplex(0, 'e', 0, 128)
43-
strconv.FormatComplex(0, 'e', 0, 256) // want `'bitSize' argument is invalid, must be either 64 or 128`
44-
strconv.FormatComplex(0, 'j', 0, 64) // want `'fmt' argument is invalid: unknown format 'j'`
45-
4635
strconv.FormatFloat(0, 'e', 0, 18) // want `'bitSize' argument is invalid, must be either 32 or 64`
4736
strconv.FormatFloat(0, 'e', 0, 32)
4837
strconv.FormatFloat(0, 'e', 0, 64)

staticcheck/testdata/src/CheckStrconv_go15/CheckStrconv.go renamed to staticcheck/testdata/src/CheckStrconv_go115/CheckStrconv.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// +build go1.15
2+
13
package pkg
24

35
import "strconv"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package pkg

0 commit comments

Comments
 (0)