@@ -39,6 +39,13 @@ func TestSeverityRulesMultiple(t *testing.T) {
3939 Path : `_test\.go` ,
4040 },
4141 },
42+ {
43+ Severity : "info" ,
44+ BaseRule : BaseRule {
45+ Text : "^nontestonly$" ,
46+ PathExcept : `_test\.go` ,
47+ },
48+ },
4249 {
4350 BaseRule : BaseRule {
4451 Source : "^//go:generate " ,
@@ -72,6 +79,8 @@ func TestSeverityRulesMultiple(t *testing.T) {
7279 {Path : "ssl.go" , Text : "ssl" , Linter : "gosec" },
7380 {Path : "e.go" , Text : "some" , Linter : "linter" },
7481 {Path : "e_test.go" , Text : "testonly" , Linter : "testlinter" },
82+ {Path : "e.go" , Text : "nontestonly" , Linter : "testlinter" },
83+ {Path : "e_test.go" , Text : "nontestonly" , Linter : "testlinter" },
7584 {Path : filepath .Join ("testdata" , "exclude_rules.go" ), Line : 3 , Linter : "lll" },
7685 {Path : filepath .Join ("testdata" , "severity_rules.go" ), Line : 3 , Linter : "invalidgo" },
7786 {Path : "someotherlinter.go" , Text : "someotherlinter" , Linter : "someotherlinter" },
@@ -97,6 +106,8 @@ func TestSeverityRulesMultiple(t *testing.T) {
97106 {Path : "ssl.go" , Text : "ssl" , Linter : "gosec" , Severity : "info" },
98107 {Path : "e.go" , Text : "some" , Linter : "linter" , Severity : "info" },
99108 {Path : "e_test.go" , Text : "testonly" , Linter : "testlinter" , Severity : "info" },
109+ {Path : "e.go" , Text : "nontestonly" , Linter : "testlinter" , Severity : "info" }, // matched
110+ {Path : "e_test.go" , Text : "nontestonly" , Linter : "testlinter" , Severity : "error" }, // not matched
100111 {Path : filepath .Join ("testdata" , "exclude_rules.go" ), Line : 3 , Linter : "lll" , Severity : "error" },
101112 {Path : filepath .Join ("testdata" , "severity_rules.go" ), Line : 3 , Linter : "invalidgo" , Severity : "info" },
102113 {Path : "someotherlinter.go" , Text : "someotherlinter" , Linter : "someotherlinter" , Severity : "info" },
0 commit comments