-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathend2end_test.go
63 lines (56 loc) · 1.33 KB
/
end2end_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"go/token"
"path"
"testing"
"github.com/quasilyte/go-consistent/internal/end2end"
)
func TestEnd2End(t *testing.T) {
filenames := []string{
"positive_tests1.go",
"positive_tests2.go",
"positive_tests3.go",
"negative_tests1.go",
"negative_tests2.go",
"negative_tests3.go",
}
for _, filename := range filenames {
t.Run(filename, func(t *testing.T) {
rel := path.Join("testdata", filename)
f, err := end2end.ParseTestFile(rel)
if err != nil {
t.Fatalf("parse %s: %v", rel, err)
}
var ctxt context
ctxt.paths = []string{rel}
_ = ctxt.initCheckers()
if err := ctxt.collectAllCandidates(); err != nil {
t.Fatalf("collect candidates: %v", err)
}
_ = ctxt.assignSuggestions()
visitWarnings(&ctxt, func(pos token.Position, v *opVariant) {
text := v.op.name + ": " + v.op.suggested.warning
mlist, ok := f.Matchers[pos.Line]
if !ok {
t.Errorf("%s: unexpected warning: %s", pos, text)
return
}
for _, m := range mlist {
if m.Match(text) {
m.Matches++
break
} else {
t.Errorf("%s: unexpected warning: %s", m.Position(), text)
}
}
})
for _, mlist := range f.Matchers {
for _, m := range mlist {
if !m.IsMatched() {
t.Errorf("%s: no matches: %s", m.Position(), m.Text())
}
}
}
})
}
}