1
1
package org.utbot.contest
2
2
3
3
import java.io.File
4
+ import java.util.concurrent.ConcurrentSkipListSet
4
5
import org.utbot.common.MutableMultiset
5
6
import org.utbot.common.mutableMultisetOf
6
7
import org.utbot.framework.plugin.api.Instruction
@@ -48,21 +49,21 @@ class GlobalStats {
48
49
get() = statsForClasses.count { it.failedToCompile }
49
50
50
51
val coveredInstructions: Int
51
- get() = statsForClasses.sumOf { it.coverage.getCoverageInfo(it.className ).covered }
52
+ get() = statsForClasses.sumOf { it.coverage.getCoverageInfo(it.testedClassNames ).covered }
52
53
53
54
val coveredInstructionsByFuzzing: Int
54
- get() = statsForClasses.sumOf { it.fuzzedCoverage.getCoverageInfo(it.className ).covered }
55
+ get() = statsForClasses.sumOf { it.fuzzedCoverage.getCoverageInfo(it.testedClassNames ).covered }
55
56
56
57
val coveredInstructionsByConcolic: Int
57
- get() = statsForClasses.sumOf { it.concolicCoverage.getCoverageInfo(it.className ).covered }
58
+ get() = statsForClasses.sumOf { it.concolicCoverage.getCoverageInfo(it.testedClassNames ).covered }
58
59
59
60
val totalInstructions: Int
60
61
get() = statsForClasses.sumOf { it.coverage.totalInstructions.toInt() }
61
62
62
63
val avgCoverage: Double
63
64
get() = statsForClasses
64
65
.filter { it.coverage.totalInstructions != 0L }
65
- .map { it.coverage.getCoverageInfo(it.className ).run { 100.0 * covered / total } }
66
+ .map { it.coverage.getCoverageInfo(it.testedClassNames ).run { 100.0 * covered / total } }
66
67
.average().run {
67
68
if (isNaN()) 0.0
68
69
else this
@@ -108,7 +109,9 @@ class GlobalStats {
108
109
avgCoverage.format(PRECISION ) + " %"
109
110
}
110
111
111
- class StatsForClass (val className : String ) {
112
+ class StatsForClass {
113
+ val testedClassNames: MutableSet <String > = ConcurrentSkipListSet ()
114
+
112
115
var methodsCount: Int = - 1
113
116
val statsForMethods = mutableListOf<StatsForMethod >()
114
117
@@ -123,8 +126,15 @@ class StatsForClass(val className: String) {
123
126
var fuzzedCoverage = CoverageInstructionsSet ()
124
127
var concolicCoverage = CoverageInstructionsSet ()
125
128
129
+ /* *
130
+ * Add class [className] to respect coverage from this class.
131
+ */
132
+ fun addTestedClass (className : String ) {
133
+ testedClassNames.add(className)
134
+ }
135
+
126
136
private fun CoverageInstructionsSet.prettyInfo (): String =
127
- getCoverageInfo(className ).run { " $covered /$total " }
137
+ getCoverageInfo(testedClassNames ).run { " $covered /$total " }
128
138
129
139
override fun toString (): String = " \n <StatsForClass> :" +
130
140
" \n\t canceled by timeout = $canceledByTimeout " +
@@ -191,12 +201,12 @@ data class CoverageInstructionsSet(
191
201
data class CoverageStatistic (val covered : Int , val total : Int )
192
202
193
203
/* *
194
- * Compute coverage of class named [className] with its anonymous, nested and inner classes .
204
+ * Compute coverage of classes with names in [classNames] .
195
205
*/
196
- private fun CoverageInstructionsSet?.getCoverageInfo (className : String ): CoverageStatistic = this ?.run {
206
+ private fun CoverageInstructionsSet?.getCoverageInfo (classNames : Set < String > ): CoverageStatistic = this ?.run {
197
207
CoverageStatistic (
198
208
coveredInstructions.filter {
199
- instr -> instr.className.startsWith( className)
209
+ instr -> classNames.contains(instr. className)
200
210
}.toSet().size,
201
211
totalInstructions.toInt()
202
212
)
0 commit comments