Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TS-38628 Partial Kotlin migration on several modules
- Loading branch information
1 parent
fa2c68e
commit f968675
Showing
57 changed files
with
743 additions
and
719 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 0 additions & 106 deletions
106
agent/src/main/java/com/teamscale/jacoco/agent/convert/Converter.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
agent/src/main/kotlin/com/teamscale/jacoco/agent/convert/Converter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package com.teamscale.jacoco.agent.convert | ||
|
||
import com.teamscale.client.TestDetails | ||
import com.teamscale.jacoco.agent.options.AgentOptionParseException | ||
import com.teamscale.jacoco.agent.util.Benchmark.benchmark | ||
import com.teamscale.jacoco.agent.util.Logging.logger | ||
import com.teamscale.jacoco.agent.util.LoggingUtils.wrap | ||
import com.teamscale.report.ReportUtils.filterByFormat | ||
import com.teamscale.report.ReportUtils.readObjects | ||
import com.teamscale.report.jacoco.EmptyReportException | ||
import com.teamscale.report.jacoco.JaCoCoXmlReportGenerator | ||
import com.teamscale.report.jacoco.dump.Dump | ||
import com.teamscale.report.testwise.ETestArtifactFormat | ||
import com.teamscale.report.testwise.TestwiseCoverageReportWriter | ||
import com.teamscale.report.testwise.jacoco.JaCoCoTestwiseReportGenerator | ||
import com.teamscale.report.testwise.model.TestExecution | ||
import com.teamscale.report.testwise.model.factory.TestInfoFactory | ||
import com.teamscale.report.util.ClasspathWildcardIncludeFilter | ||
import com.teamscale.report.util.CommandLineLogger | ||
import org.jacoco.core.tools.ExecFileLoader | ||
import java.io.IOException | ||
import java.nio.file.Paths | ||
|
||
/** Converts one .exec binary coverage file to XML. */ | ||
class Converter(private val arguments: ConvertCommand) { | ||
|
||
/** Converts one .exec binary coverage file to XML. */ | ||
@Throws(IOException::class, AgentOptionParseException::class) | ||
fun runJaCoCoReportGeneration() { | ||
benchmark("Generating the XML report") { | ||
val loader = ExecFileLoader().apply { | ||
arguments.getInputFiles() | ||
.filterByFormat(ETestArtifactFormat.JACOCO) | ||
.forEach { load(it) } | ||
} | ||
val sessionInfo = loader.sessionInfoStore.getMerged("merged") | ||
val executionDataStore = loader.executionDataStore | ||
|
||
try { | ||
JaCoCoXmlReportGenerator( | ||
arguments.getClassDirectoriesOrZips(), | ||
wildcardIncludeExcludeFilter, | ||
arguments.duplicateClassFileBehavior, | ||
arguments.shouldIgnoreUncoveredClasses, | ||
wrap(logger) | ||
).convert( | ||
Dump(sessionInfo, executionDataStore), | ||
Paths.get(arguments.outputFile).toFile() | ||
) | ||
} catch (e: EmptyReportException) { | ||
logger.warn(e.localizedMessage) | ||
} | ||
} | ||
} | ||
|
||
/** Converts one .exec binary coverage file, test details and test execution files to JSON testwise coverage. */ | ||
@Throws(IOException::class, AgentOptionParseException::class) | ||
fun runTestwiseCoverageReportGeneration() { | ||
val testDetails = arguments.getInputFiles().readObjects<TestDetails>( | ||
ETestArtifactFormat.TEST_LIST | ||
) | ||
val testExecutions = arguments.getInputFiles().readObjects<TestExecution>( | ||
ETestArtifactFormat.TEST_EXECUTION | ||
) | ||
val logger = CommandLineLogger() | ||
benchmark("Generating the testwise coverage report") { | ||
logger.info( | ||
"Writing report with " + testDetails.size + " Details/" + testExecutions.size + " Results" | ||
) | ||
|
||
TestwiseCoverageReportWriter( | ||
TestInfoFactory(testDetails, testExecutions), | ||
arguments.getOutputFile(), | ||
arguments.splitAfter | ||
).use { coverageWriter -> | ||
arguments.getInputFiles() | ||
.filterByFormat(ETestArtifactFormat.JACOCO) | ||
.forEach { executionDataFile -> | ||
JaCoCoTestwiseReportGenerator( | ||
arguments.getClassDirectoriesOrZips(), | ||
wildcardIncludeExcludeFilter, | ||
arguments.duplicateClassFileBehavior, | ||
logger | ||
).convertAndConsume(executionDataFile, coverageWriter) | ||
} | ||
} | ||
} | ||
} | ||
|
||
private val wildcardIncludeExcludeFilter: ClasspathWildcardIncludeFilter | ||
get() = ClasspathWildcardIncludeFilter( | ||
arguments.locationIncludeFilters.joinToString(":"), | ||
arguments.locationExcludeFilters.joinToString(":") | ||
) | ||
} |
12 changes: 12 additions & 0 deletions
12
agent/src/main/kotlin/com/teamscale/jacoco/agent/util/Benchmark.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.teamscale.jacoco.agent.util | ||
|
||
import com.teamscale.jacoco.agent.util.Logging.logger | ||
import kotlin.time.measureTime | ||
|
||
object Benchmark { | ||
/** | ||
* Measures how long a certain piece of code takes and logs it to the debug log. | ||
*/ | ||
fun Any.benchmark(name: String, block: () -> Unit) = | ||
logger.debug("$name took ${measureTime(block)} ms") | ||
} |
Oops, something went wrong.