Skip to content

Commit 3286cca

Browse files
committed
Add tests for coverage filters
1 parent dfd7492 commit 3286cca

12 files changed

+218
-6
lines changed

Diff for: .gitignore

-4
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,3 @@ docs/_spec/.jekyll-metadata
9999

100100
# scaladoc related
101101
scaladoc/output/
102-
103-
#coverage
104-
coverage/
105-

Diff for: compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ trait CommonScalaSettings:
127127

128128
/* Coverage settings */
129129
val coverageOutputDir = PathSetting("-coverage-out", "Destination for coverage classfiles and instrumentation data.", "", aliases = List("--coverage-out"))
130-
val coverageExcludePackages: Setting[List[String]] = MultiStringSetting("-coverage-exclude-packages", "packages", "Semicolon separated list of regexes for packages to exclude from coverage.", aliases = List("--coverage-exclude-packages"))
131-
val coverageExcludeFiles: Setting[List[String]] = MultiStringSetting("-coverage-exclude-files", "files", "Semicolon separated list of regexes for files to exclude from coverage.", aliases = List("--coverage-exclude-files"))
130+
val coverageExcludePackages: Setting[List[String]] = MultiStringSetting("-coverage-exclude-packages", "packages", "List of regexes for packages to exclude from coverage.", aliases = List("--coverage-exclude-packages"))
131+
val coverageExcludeFiles: Setting[List[String]] = MultiStringSetting("-coverage-exclude-files", "files", "List of regexes for files to exclude from coverage.", aliases = List("--coverage-exclude-files"))
132132

133133
/* Other settings */
134134
val encoding: Setting[String] = StringSetting("-encoding", "encoding", "Specify character encoding used by source files.", Properties.sourceEncoding, aliases = List("--encoding"))

Diff for: tests/coverage/pos/ExcludeClass.scala

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//> using options -coverage-exclude-packages:covtest.Klass
2+
3+
package covtest
4+
5+
class Klass {
6+
def abs(i: Int) =
7+
if i > 0 then
8+
i
9+
else
10+
-i
11+
}
12+
13+
class Klass2 {
14+
def abs(i: Int) =
15+
if i > 0 then
16+
i
17+
else
18+
-i
19+
}

Diff for: tests/coverage/pos/ExcludeClass.scoverage.check

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Coverage data, format version: 3.0
2+
# Statement data:
3+
# - id
4+
# - source path
5+
# - package name
6+
# - class name
7+
# - class type (Class, Object or Trait)
8+
# - full class name
9+
# - method name
10+
# - start offset
11+
# - end offset
12+
# - line number
13+
# - symbol name
14+
# - tree name
15+
# - is branch
16+
# - invocations count
17+
# - is ignored
18+
# - description (can be multi-line)
19+
# ' ' sign
20+
# ------------------------------------------
21+
0
22+
ExcludeClass.scala
23+
covtest
24+
Klass2
25+
Class
26+
covtest.Klass2
27+
abs
28+
217
29+
218
30+
16
31+
i
32+
Ident
33+
true
34+
0
35+
false
36+
i
37+
38+
1
39+
ExcludeClass.scala
40+
covtest
41+
Klass2
42+
Class
43+
covtest.Klass2
44+
abs
45+
234
46+
236
47+
18
48+
unary_-
49+
Select
50+
true
51+
0
52+
false
53+
-i
54+
55+
2
56+
ExcludeClass.scala
57+
covtest
58+
Klass2
59+
Class
60+
covtest.Klass2
61+
abs
62+
175
63+
182
64+
14
65+
abs
66+
DefDef
67+
false
68+
0
69+
false
70+
def abs
71+

Diff for: tests/coverage/pos/ExcludeDef.scala

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//> using options -coverage-exclude-packages:covtest\..*
2+
3+
package covtest
4+
5+
def abs(i: Int) =
6+
if i > 0 then
7+
i
8+
else
9+
-i

Diff for: tests/coverage/pos/ExcludeDef.scoverage.check

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Coverage data, format version: 3.0
2+
# Statement data:
3+
# - id
4+
# - source path
5+
# - package name
6+
# - class name
7+
# - class type (Class, Object or Trait)
8+
# - full class name
9+
# - method name
10+
# - start offset
11+
# - end offset
12+
# - line number
13+
# - symbol name
14+
# - tree name
15+
# - is branch
16+
# - invocations count
17+
# - is ignored
18+
# - description (can be multi-line)
19+
# ' ' sign
20+
# ------------------------------------------

Diff for: tests/coverage/pos/ExcludeFile.scala

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//> using options -coverage-exclude-files:.*ExcludeFile
2+
3+
package covtest
4+
5+
class Klass {
6+
def abs(i: Int) =
7+
if i > 0 then
8+
i
9+
else
10+
-i
11+
}

Diff for: tests/coverage/pos/ExcludeFile.scoverage.check

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Coverage data, format version: 3.0
2+
# Statement data:
3+
# - id
4+
# - source path
5+
# - package name
6+
# - class name
7+
# - class type (Class, Object or Trait)
8+
# - full class name
9+
# - method name
10+
# - start offset
11+
# - end offset
12+
# - line number
13+
# - symbol name
14+
# - tree name
15+
# - is branch
16+
# - invocations count
17+
# - is ignored
18+
# - description (can be multi-line)
19+
# ' ' sign
20+
# ------------------------------------------

Diff for: tests/coverage/pos/ExcludeOtherStuff.scala

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//> using options -coverage-exclude-packages:covtest.Oject,covtest.Tait
2+
3+
package covtest
4+
5+
object Oject {
6+
def abs(i: Int) =
7+
if i > 0 then
8+
i
9+
else
10+
-i
11+
}
12+
13+
trait Tait {
14+
def abs(i: Int): Int
15+
}

Diff for: tests/coverage/pos/ExcludeOtherStuff.scoverage.check

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Coverage data, format version: 3.0
2+
# Statement data:
3+
# - id
4+
# - source path
5+
# - package name
6+
# - class name
7+
# - class type (Class, Object or Trait)
8+
# - full class name
9+
# - method name
10+
# - start offset
11+
# - end offset
12+
# - line number
13+
# - symbol name
14+
# - tree name
15+
# - is branch
16+
# - invocations count
17+
# - is ignored
18+
# - description (can be multi-line)
19+
# ' ' sign
20+
# ------------------------------------------

Diff for: tests/coverage/pos/ExcludePackage.scala

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//> using options -coverage-exclude-packages:covtest
2+
3+
package covtest
4+
5+
class Klass {
6+
def abs(i: Int) =
7+
if i > 0 then
8+
i
9+
else
10+
-i
11+
}

Diff for: tests/coverage/pos/ExcludePackage.scoverage.check

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Coverage data, format version: 3.0
2+
# Statement data:
3+
# - id
4+
# - source path
5+
# - package name
6+
# - class name
7+
# - class type (Class, Object or Trait)
8+
# - full class name
9+
# - method name
10+
# - start offset
11+
# - end offset
12+
# - line number
13+
# - symbol name
14+
# - tree name
15+
# - is branch
16+
# - invocations count
17+
# - is ignored
18+
# - description (can be multi-line)
19+
# ' ' sign
20+
# ------------------------------------------

0 commit comments

Comments
 (0)