Skip to content

Commit 82aaf0d

Browse files
committed
tests: update global tests
1 parent 7bfb0cb commit 82aaf0d

File tree

9 files changed

+36
-82
lines changed

9 files changed

+36
-82
lines changed

test/run_test.go

+15-36
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ import (
1414
const minimalPkg = "minimalpkg"
1515

1616
func TestAutogeneratedNoIssues(t *testing.T) {
17+
cfg := `
18+
linters:
19+
exclusions:
20+
generated: lax
21+
`
22+
1723
testshared.NewRunnerBuilder(t).
24+
WithConfig(cfg).
1825
WithTargetPath(testdataDir, "autogenerated").
1926
Runner().
2027
Install().
@@ -270,7 +277,6 @@ func TestLineDirectiveProcessedFiles(t *testing.T) {
270277
desc: "lite loading",
271278
args: []string{
272279
"--output.text.print-issued-lines=false",
273-
"--exclude-use-default=false",
274280
"-Erevive",
275281
},
276282
target: "quicktemplate",
@@ -285,7 +291,6 @@ func TestLineDirectiveProcessedFiles(t *testing.T) {
285291
desc: "full loading",
286292
args: []string{
287293
"--output.text.print-issued-lines=false",
288-
"--exclude-use-default=false",
289294
"-Erevive,govet",
290295
},
291296
target: "quicktemplate",
@@ -316,8 +321,15 @@ func TestLineDirectiveProcessedFiles(t *testing.T) {
316321
}
317322

318323
func TestUnsafeOk(t *testing.T) {
324+
cfg := `
325+
linters:
326+
exclusions:
327+
presets:
328+
- commonFalsePositives
329+
`
330+
319331
testshared.NewRunnerBuilder(t).
320-
WithNoConfig().
332+
WithConfig(cfg).
321333
WithArgs("--enable-all").
322334
WithTargetPath(testdataDir, "unsafe").
323335
Runner().
@@ -361,39 +373,6 @@ func TestSortedResults(t *testing.T) {
361373
}
362374
}
363375

364-
func TestSkippedDirsNoMatchArg(t *testing.T) {
365-
dir := filepath.Join(testdataDir, "skipdirs", "skip_me", "nested")
366-
367-
testshared.NewRunnerBuilder(t).
368-
WithNoConfig().
369-
WithArgs(
370-
"--output.text.print-issued-lines=false",
371-
"--exclude-dirs", dir,
372-
"-Erevive",
373-
).
374-
WithTargetPath(dir).
375-
Runner().
376-
Install().
377-
Run().
378-
ExpectExitCode(exitcodes.IssuesFound).
379-
ExpectOutputEq("testdata/skipdirs/skip_me/nested/with_issue.go:8:9: " +
380-
"indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)\n")
381-
}
382-
383-
func TestSkippedDirsTestdata(t *testing.T) {
384-
testshared.NewRunnerBuilder(t).
385-
WithNoConfig().
386-
WithArgs(
387-
"--output.text.print-issued-lines=false",
388-
"-Erevive",
389-
).
390-
WithTargetPath(testdataDir, "skipdirs", "...").
391-
Runner().
392-
Install().
393-
Run().
394-
ExpectNoIssues() // all was skipped because in testdata
395-
}
396-
397376
func TestIdentifierUsedOnlyInTests(t *testing.T) {
398377
testshared.NewRunnerBuilder(t).
399378
WithNoConfig().

test/testdata/cgo/main.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package cgoexample ...
12
package cgoexample
23

34
/*
@@ -14,6 +15,7 @@ import (
1415
"unsafe"
1516
)
1617

18+
// Example ...
1719
func Example() {
1820
cs := C.CString("Hello from stdio\n")
1921
C.myprint(cs)
+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
version: "2"
22

3-
issues:
4-
include:
5-
- EXC0011 # include issues about comments from `stylecheck`
3+
linters:
4+
exclusions:
5+
presets:
6+
- stdErrorHandling
7+
- commonFalsePositives
8+
- legacy

test/testdata/configs/path-except.yml

+8-7
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ linters-settings:
66
- fmt\.Print.*
77
- time.Sleep(# no sleeping!)?
88

9-
issues:
10-
exclude-rules:
11-
# Apply forbidigo only to test files, exclude
12-
# it everywhere else.
13-
- path-except: _test\.go
14-
linters:
15-
- forbidigo
9+
linters:
10+
exclusions:
11+
rules:
12+
# Apply forbidigo only to test files, exclude
13+
# it everywhere else.
14+
- path-except: _test\.go
15+
linters:
16+
- forbidigo

test/testdata/default_exclude.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
/*Package testdata ...*/
55
package testdata
66

7-
// InvalidFuncComment, both revive and stylecheck will complain about this, // want stylecheck:`ST1020: comment on exported function ExportedFunc1 should be of the form "ExportedFunc1 ..."`
7+
// InvalidFuncComment, both revive and stylecheck will complain about this, // want `exported: comment on exported function ExportedFunc1 should be of the form "ExportedFunc1 ..."`
88
// if include EXC0011, only the warning from revive will be ignored.
99
// And only the warning from stylecheck will start with "ST1020".
1010
func ExportedFunc1() {
1111
}
1212

13-
// InvalidFuncComment // want stylecheck:`ST1020: comment on exported function ExportedFunc2 should be of the form "ExportedFunc2 ..."`
13+
// InvalidFuncComment // want `ST1020: comment on exported function ExportedFunc2 should be of the form "ExportedFunc2 ..."`
1414
//
1515
//nolint:revive
1616
func ExportedFunc2() {
1717
}
1818

1919
//nolint:stylecheck
20-
func IgnoreAll() {
20+
func IgnoreAll() { // want "exported: exported function IgnoreAll should have comment or be unexported"
2121
}

test/testdata/skipdirs/examples/with_issue.go

-11
This file was deleted.

test/testdata/skipdirs/examples_no_skip/with_issue.go

-11
This file was deleted.

test/testdata/skipdirs/skip_me/nested/with_issue.go

-11
This file was deleted.

test/testdata/unsafe/pkg.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
// Package pkg ...
12
package pkg
23

34
import (
45
"log"
56
"unsafe"
67
)
78

9+
// F ...
810
func F() {
911
x := 123 // of type int
1012
p := unsafe.Pointer(&x)

0 commit comments

Comments
 (0)