@@ -4,50 +4,56 @@ import scala.reflect.internal.util.BatchSourceFile
4
4
import scala .reflect .internal .util .NoFile
5
5
import scala .reflect .internal .util .SourceFile
6
6
import scala .reflect .io .VirtualFile
7
+ import scala .tools .nsc .reporters .ConsoleReporter
8
+ import scala .tools .nsc .Settings
7
9
8
10
import munit .FunSuite
9
11
10
12
class RegexCoverageFilterTest extends FunSuite {
11
13
14
+ val reporter = new ConsoleReporter (new Settings ())
15
+
12
16
test(" isClassIncluded should return true for empty excludes" ) {
13
- assert(new RegexCoverageFilter (Nil , Nil , Nil ).isClassIncluded(" x" ))
17
+ assert(
18
+ new RegexCoverageFilter (Nil , Nil , Nil , reporter).isClassIncluded(" x" )
19
+ )
14
20
}
15
21
16
22
test(" should not crash for empty input" ) {
17
- assert(new RegexCoverageFilter (Nil , Nil , Nil ).isClassIncluded(" " ))
23
+ assert(new RegexCoverageFilter (Nil , Nil , Nil , reporter ).isClassIncluded(" " ))
18
24
}
19
25
20
26
test(" should exclude scoverage -> scoverage" ) {
21
27
assert(
22
- ! new RegexCoverageFilter (Seq (" scoverage" ), Nil , Nil )
28
+ ! new RegexCoverageFilter (Seq (" scoverage" ), Nil , Nil , reporter )
23
29
.isClassIncluded(" scoverage" )
24
30
)
25
31
}
26
32
27
33
test(" should include scoverage -> scoverageeee" ) {
28
34
assert(
29
- new RegexCoverageFilter (Seq (" scoverage" ), Nil , Nil )
35
+ new RegexCoverageFilter (Seq (" scoverage" ), Nil , Nil , reporter )
30
36
.isClassIncluded(" scoverageeee" )
31
37
)
32
38
}
33
39
34
40
test(" should exclude scoverage* -> scoverageeee" ) {
35
41
assert(
36
- ! new RegexCoverageFilter (Seq (" scoverage*" ), Nil , Nil )
42
+ ! new RegexCoverageFilter (Seq (" scoverage*" ), Nil , Nil , reporter )
37
43
.isClassIncluded(" scoverageeee" )
38
44
)
39
45
}
40
46
41
47
test(" should include eee -> scoverageeee" ) {
42
48
assert(
43
- new RegexCoverageFilter (Seq (" eee" ), Nil , Nil )
49
+ new RegexCoverageFilter (Seq (" eee" ), Nil , Nil , reporter )
44
50
.isClassIncluded(" scoverageeee" )
45
51
)
46
52
}
47
53
48
54
test(" should exclude .*eee -> scoverageeee" ) {
49
55
assert(
50
- ! new RegexCoverageFilter (Seq (" .*eee" ), Nil , Nil )
56
+ ! new RegexCoverageFilter (Seq (" .*eee" ), Nil , Nil , reporter )
51
57
.isClassIncluded(" scoverageeee" )
52
58
)
53
59
}
@@ -56,91 +62,97 @@ class RegexCoverageFilterTest extends FunSuite {
56
62
57
63
test(" isFileIncluded should return true for empty excludes" ) {
58
64
val file = new BatchSourceFile (abstractFile, Array .emptyCharArray)
59
- assert(new RegexCoverageFilter (Nil , Nil , Nil ).isFileIncluded(file))
65
+ assert(
66
+ new RegexCoverageFilter (Nil , Nil , Nil , reporter).isFileIncluded(file)
67
+ )
60
68
}
61
69
62
70
test(" should exclude by filename" ) {
63
71
val file = new BatchSourceFile (abstractFile, Array .emptyCharArray)
64
72
assert(
65
- ! new RegexCoverageFilter (Nil , Seq (" sammy" ), Nil )
73
+ ! new RegexCoverageFilter (Nil , Seq (" sammy" ), Nil , reporter )
66
74
.isFileIncluded(file)
67
75
)
68
76
}
69
77
70
78
test(" should exclude by regex wildcard" ) {
71
79
val file = new BatchSourceFile (abstractFile, Array .emptyCharArray)
72
80
assert(
73
- ! new RegexCoverageFilter (Nil , Seq (" sam.*" ), Nil )
81
+ ! new RegexCoverageFilter (Nil , Seq (" sam.*" ), Nil , reporter )
74
82
.isFileIncluded(file)
75
83
)
76
84
}
77
85
78
86
test(" should not exclude non matching regex" ) {
79
87
val file = new BatchSourceFile (abstractFile, Array .emptyCharArray)
80
88
assert(
81
- new RegexCoverageFilter (Nil , Seq (" qweqeqwe" ), Nil )
89
+ new RegexCoverageFilter (Nil , Seq (" qweqeqwe" ), Nil , reporter )
82
90
.isFileIncluded(file)
83
91
)
84
92
}
85
93
86
94
val options = ScoverageOptions .default()
87
95
88
96
test(" isSymbolIncluded should return true for empty excludes" ) {
89
- assert(new RegexCoverageFilter (Nil , Nil , Nil ).isSymbolIncluded(" x" ))
97
+ assert(
98
+ new RegexCoverageFilter (Nil , Nil , Nil , reporter).isSymbolIncluded(" x" )
99
+ )
90
100
}
91
101
92
102
test(" should not crash for empty input" ) {
93
- assert(new RegexCoverageFilter (Nil , Nil , Nil ).isSymbolIncluded(" " ))
103
+ assert(
104
+ new RegexCoverageFilter (Nil , Nil , Nil , reporter).isSymbolIncluded(" " )
105
+ )
94
106
}
95
107
96
108
test(" should exclude scoverage -> scoverage" ) {
97
109
assert(
98
- ! new RegexCoverageFilter (Nil , Nil , Seq (" scoverage" ))
110
+ ! new RegexCoverageFilter (Nil , Nil , Seq (" scoverage" ), reporter )
99
111
.isSymbolIncluded(" scoverage" )
100
112
)
101
113
}
102
114
103
115
test(" should include scoverage -> scoverageeee" ) {
104
116
assert(
105
- new RegexCoverageFilter (Nil , Nil , Seq (" scoverage" ))
117
+ new RegexCoverageFilter (Nil , Nil , Seq (" scoverage" ), reporter )
106
118
.isSymbolIncluded(" scoverageeee" )
107
119
)
108
120
}
109
121
test(" should exclude scoverage* -> scoverageeee" ) {
110
122
assert(
111
- ! new RegexCoverageFilter (Nil , Nil , Seq (" scoverage*" ))
123
+ ! new RegexCoverageFilter (Nil , Nil , Seq (" scoverage*" ), reporter )
112
124
.isSymbolIncluded(" scoverageeee" )
113
125
)
114
126
}
115
127
116
128
test(" should include eee -> scoverageeee" ) {
117
129
assert(
118
- new RegexCoverageFilter (Nil , Nil , Seq (" eee" ))
130
+ new RegexCoverageFilter (Nil , Nil , Seq (" eee" ), reporter )
119
131
.isSymbolIncluded(" scoverageeee" )
120
132
)
121
133
}
122
134
123
135
test(" should exclude .*eee -> scoverageeee" ) {
124
136
assert(
125
- ! new RegexCoverageFilter (Nil , Nil , Seq (" .*eee" ))
137
+ ! new RegexCoverageFilter (Nil , Nil , Seq (" .*eee" ), reporter )
126
138
.isSymbolIncluded(" scoverageeee" )
127
139
)
128
140
}
129
141
test(" should exclude scala.reflect.api.Exprs.Expr" ) {
130
142
assert(
131
- ! new RegexCoverageFilter (Nil , Nil , options.excludedSymbols)
143
+ ! new RegexCoverageFilter (Nil , Nil , options.excludedSymbols, reporter )
132
144
.isSymbolIncluded(" scala.reflect.api.Exprs.Expr" )
133
145
)
134
146
}
135
147
test(" should exclude scala.reflect.macros.Universe.Tree" ) {
136
148
assert(
137
- ! new RegexCoverageFilter (Nil , Nil , options.excludedSymbols)
149
+ ! new RegexCoverageFilter (Nil , Nil , options.excludedSymbols, reporter )
138
150
.isSymbolIncluded(" scala.reflect.macros.Universe.Tree" )
139
151
)
140
152
}
141
153
test(" should exclude scala.reflect.api.Trees.Tree" ) {
142
154
assert(
143
- ! new RegexCoverageFilter (Nil , Nil , options.excludedSymbols)
155
+ ! new RegexCoverageFilter (Nil , Nil , options.excludedSymbols, reporter )
144
156
.isSymbolIncluded(" scala.reflect.api.Trees.Tree" )
145
157
)
146
158
}
@@ -158,7 +170,7 @@ class RegexCoverageFilterTest extends FunSuite {
158
170
|8
159
171
""" .stripMargin
160
172
161
- val numbers = new RegexCoverageFilter (Nil , Nil , Nil )
173
+ val numbers = new RegexCoverageFilter (Nil , Nil , Nil , reporter )
162
174
.getExcludedLineNumbers(mockSourceFile(file))
163
175
assertEquals(numbers, List .empty)
164
176
}
@@ -182,7 +194,7 @@ class RegexCoverageFilterTest extends FunSuite {
182
194
|16
183
195
""" .stripMargin
184
196
185
- val numbers = new RegexCoverageFilter (Nil , Nil , Nil )
197
+ val numbers = new RegexCoverageFilter (Nil , Nil , Nil , reporter )
186
198
.getExcludedLineNumbers(mockSourceFile(file))
187
199
assertEquals(numbers, List (Range (4 , 9 ), Range (12 , 14 )))
188
200
}
@@ -205,7 +217,7 @@ class RegexCoverageFilterTest extends FunSuite {
205
217
|15
206
218
""" .stripMargin
207
219
208
- val numbers = new RegexCoverageFilter (Nil , Nil , Nil )
220
+ val numbers = new RegexCoverageFilter (Nil , Nil , Nil , reporter )
209
221
.getExcludedLineNumbers(mockSourceFile(file))
210
222
assertEquals(numbers, List (Range (4 , 9 ), Range (12 , 16 )))
211
223
}
@@ -228,7 +240,7 @@ class RegexCoverageFilterTest extends FunSuite {
228
240
|15
229
241
""" .stripMargin
230
242
231
- val numbers = new RegexCoverageFilter (Nil , Nil , Nil )
243
+ val numbers = new RegexCoverageFilter (Nil , Nil , Nil , reporter )
232
244
.getExcludedLineNumbers(mockSourceFile(file))
233
245
assertEquals(numbers, List (Range (4 , 9 ), Range (12 , 16 )))
234
246
}
0 commit comments