Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import com.google.common.base.Strings;
import com.teamscale.client.CommitDescriptor;
import com.teamscale.client.EReportFormat;
import com.teamscale.client.HttpUtils;
import com.teamscale.client.ITeamscaleService;
import com.teamscale.client.ITeamscaleServiceKt;
import com.teamscale.client.TeamscaleServer;
import com.teamscale.client.TeamscaleServiceGenerator;
import com.teamscale.jacoco.agent.upload.IUploadRetry;
Expand Down Expand Up @@ -133,9 +133,8 @@ private boolean tryUploading(CoverageFile coverageFile, TeamscaleServer teamscal
// Cannot be executed in the constructor as this causes issues in WildFly server
// (See #100)
ITeamscaleService api = TeamscaleServiceGenerator.createService(ITeamscaleService.class,
teamscaleServer.url, teamscaleServer.userName, teamscaleServer.userAccessToken,
HttpUtils.DEFAULT_READ_TIMEOUT, HttpUtils.DEFAULT_WRITE_TIMEOUT);
api.uploadReport(teamscaleServer.project, teamscaleServer.commit, teamscaleServer.revision,
teamscaleServer.url, teamscaleServer.userName, teamscaleServer.userAccessToken);
ITeamscaleServiceKt.uploadReport(api, teamscaleServer.project, teamscaleServer.commit, teamscaleServer.revision,
teamscaleServer.repository, teamscaleServer.partition, EReportFormat.JACOCO,
teamscaleServer.getMessage(), coverageFile.createFormRequestBody());
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ private static AgentOptions parseProxyOptions(String otherOptionsString, ProxySy
String proxyPasswordOption = String.format("proxy-%s-password=%s", protocol, expectedPassword);
String optionsString = String.format("%s%s,%s,%s,%s", otherOptionsString, proxyHostOption, proxyPortOption, proxyUserOption, proxyPasswordOption);

if(passwordFile != null) {
if (passwordFile != null) {
String proxyPasswordFileOption = String.format("proxy-password-file=%s", passwordFile.getAbsoluteFile());
optionsString += "," + proxyPasswordFileOption;
}
Expand All @@ -465,11 +465,7 @@ private void assertTeamscaleProxySystemPropertiesAreCorrect(ProxySystemPropertie
}

private void clearTeamscaleProxySystemProperties(ProxySystemProperties.Protocol protocol) {
TeamscaleProxySystemProperties teamscaleProxySystemProperties = new TeamscaleProxySystemProperties(protocol);
teamscaleProxySystemProperties.setProxyHost("");
teamscaleProxySystemProperties.setProxyPort("");
teamscaleProxySystemProperties.setProxyUser("");
teamscaleProxySystemProperties.setProxyPassword("");
new TeamscaleProxySystemProperties(protocol).clear();
}
/** Returns the include filter predicate for the given filter expression. */
private static Predicate<String> includeFilter(String filterString) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ void testTeamscaleProxyOptionsFilledWithJVMOptionsOnInit() {
assertThat(teamscaleProxyOptions.proxyUser).isEqualTo(expectedUser);
assertThat(teamscaleProxyOptions.proxyPassword).isEqualTo(expectedPassword);

proxySystemProperties.setProxyHost("");
proxySystemProperties.setProxyPort("");
proxySystemProperties.setProxyUser("");
proxySystemProperties.setProxyPassword("");
proxySystemProperties.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public Optional<UniqueId> convertToUniqueId(PrioritizableTest test) {
LOGGER.severe(() -> "Retrieved invalid test '" + test.testName + "' from Teamscale server!");
LOGGER.severe(() -> "The following seem related:");
uniformPathToUniqueIdMapping.keySet().stream().sorted(Comparator
.comparing(testPath -> StringUtils.editDistance(test.testName, testPath))).limit(5)
.comparing(testPath -> StringUtils.levenshteinDistance(test.testName, testPath))).limit(5)
.forEach(testAlternative -> LOGGER.severe(() -> " - " + testAlternative));
}
return Optional.ofNullable(clusterUniqueId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
* {@link Analyzer} requires a {@link ExecutionDataStore} instance that holds
* the execution data for the classes to analyze. The {@link Analyzer} offers
* several methods to analyze classes from a variety of sources.
* <p>
* CAUTION: Do not convert to Kotlin. This class has to stay in Java for future maintenance reasons!
*/
public class OpenAnalyzer {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
* <p>
* When updating JaCoCo make a diff of the previous {@link org.jacoco.core.internal.analysis.InstructionsBuilder}
* implementation and the new implementation and update this class accordingly.
* <p>
* CAUTION: Do not convert to Kotlin. This class has to stay in Java for future maintenance reasons!
*/
public class CachingInstructionsBuilder extends InstructionsBuilder {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.teamscale.report.testwise.ETestArtifactFormat
import com.teamscale.report.testwise.model.TestExecution
import com.teamscale.report.testwise.model.TestwiseCoverageReport
import java.io.File
import java.io.FileFilter
import java.io.IOException
import java.util.*

Expand Down Expand Up @@ -39,7 +38,7 @@ object ReportUtils {
@Throws(JsonProcessingException::class)
fun getTestwiseCoverageReportAsString(
report: TestwiseCoverageReport
): String = JsonUtils.serialize(report)
) = JsonUtils.serialize(report)

/** Writes the report object to the given file as json. */
@Throws(IOException::class)
Expand All @@ -59,7 +58,7 @@ object ReportUtils {
clazz: Class<Array<T>>,
directoriesOrFiles: List<File>
) = listFiles(format, directoriesOrFiles)
.mapNotNull { JsonUtils.deserializeFile(it, clazz) }
.map { JsonUtils.deserializeFile(it, clazz) }
.flatMap { listOf(*it) }

/** Recursively lists all files of the given artifact type. */
Expand All @@ -70,14 +69,14 @@ object ReportUtils {
) = directoriesOrFiles.flatMap { directoryOrFile ->
when {
directoryOrFile.isDirectory() -> {
FileSystemUtils.listFilesRecursively(directoryOrFile) {
it.isOfArtifactFormat(format)
}
directoryOrFile.walkTopDown().filter { it.isOfArtifactFormat(format) }.toList()
}

directoryOrFile.isOfArtifactFormat(format) -> {
listOf(directoryOrFile)
}
else -> emptyList<File>()

else -> emptyList()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ class JaCoCoXmlReportGenerator(
analyzeStructureAndAnnotateCoverage(mergedStore).apply {
checkForEmptyReport()
coverageFile.outputStream.use { outputStream ->
createReport(
outputStream, this, dump.info, mergedStore)
createReport(outputStream, this, dump.info, mergedStore)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ internal class TeamscaleCoverageBuilder(
// we do not log the exception here as it does not provide additional valuable information
// and may confuse users into thinking there's a serious
// problem with the agent due to the stack traces in the log
logger.warn("Ignoring duplicate, non-identical class file for class ${coverage.name} compiled " +
"from source file ${coverage.sourceFileName}. This happens when a class with the same " +
"fully-qualified name is loaded twice but the two loaded class files are not identical. " +
"A common reason for this is that the same library or shared code is included twice in " +
"your application but in two different versions. The produced coverage for this class " +
"may not be accurate or may even be unusable. To fix this problem, please resolve the " +
"conflict between both class files in your application.")
logger.warn(
"Ignoring duplicate, non-identical class file for class ${coverage.name} compiled " +
"from source file ${coverage.sourceFileName}. This happens when a class with the same " +
"fully-qualified name is loaded twice but the two loaded class files are not identical. " +
"A common reason for this is that the same library or shared code is included twice in " +
"your application but in two different versions. The produced coverage for this class " +
"may not be accurate or may even be unusable. To fix this problem, please resolve the " +
"conflict between both class files in your application."
)
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ package com.teamscale.report.testwise
import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter
import com.teamscale.client.JsonUtils
import com.teamscale.client.StringUtils
import com.teamscale.report.testwise.model.TestInfo
import com.teamscale.report.testwise.model.builder.TestCoverageBuilder
import com.teamscale.report.testwise.model.factory.TestInfoFactory
import java.io.File
import java.io.IOException
import java.io.OutputStream
import java.nio.file.Files
import java.util.function.Consumer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ open class CachingExecutionDataReader(
*/
private fun analyzeDirectory(classDir: File, analyzer: AnalyzerCache) =
runCatching { analyzer.analyzeAll(classDir) }
.onFailure { e -> logger.error("Failed to analyze class files in $classDir! " +
"Maybe the folder contains incompatible class files. Coverage for class files " +
"in this folder will be ignored.", e) }
.onFailure { e ->
logger.error(
"Failed to analyze class files in $classDir! " +
"Maybe the folder contains incompatible class files. Coverage for class files " +
"in this folder will be ignored.", e
)
}
.getOrDefault(0)

/**
Expand All @@ -73,7 +77,7 @@ open class CachingExecutionDataReader(

/**
* Consumer for processing [Dump] objects and passing them to [TestCoverageBuilder].
*
*
* @param logger The logger to use for logging.
* @param locationIncludeFilter The filter to use for including locations.
* @param nextConsumer The consumer to pass the generated [TestCoverageBuilder] to.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ open class JaCoCoTestwiseReportGenerator(
}

/** Collects execution information per session and passes it to the consumer . */
private class DumpCallback(private val consumer: DumpConsumer) : IExecutionDataVisitor, ISessionInfoVisitor {
private class DumpCallback(
private val consumer: DumpConsumer
) : IExecutionDataVisitor, ISessionInfoVisitor {
/** The dump that is currently being read. */
private var currentDump: Dump? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import org.jacoco.core.internal.analysis.StringPool
import org.jacoco.core.internal.data.CRC64
import org.jacoco.core.internal.flow.ClassProbesAdapter
import org.jacoco.core.internal.instr.InstrSupport
import org.objectweb.asm.ClassReader
import org.objectweb.asm.ClassVisitor
import java.io.IOException
import java.io.InputStream
import java.nio.file.Files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ClassCoverageLookup internal constructor(
probes.size > executedProbes.size -> throw CoverageGenerationException(
"Probe lookup does not match with actual probe size for $sourceFileName $className (${probes.size} vs ${executedProbes.size})! This is a bug in the profiler tooling. Please report it back to CQSE."
)

sourceFileName == null -> {
logger.warn("No source file name found for class $className! This class was probably not compiled with debug information enabled!")
return null
Expand All @@ -60,6 +61,7 @@ class ClassCoverageLookup internal constructor(
coveredLines.isEmpty() -> logger.debug(
"$sourceFileName $className contains a method with no line information. Does the class contain debug information?"
)

else -> fileCoverage.addLines(coveredLines)
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package com.teamscale.report.testwise.model.builder

import com.teamscale.client.TestDetails
import com.teamscale.report.testwise.model.TestExecution
import com.teamscale.report.testwise.model.TestInfo
import com.teamscale.report.testwise.model.TestwiseCoverageReport
import java.util.function.Function

/** Container for coverage produced by multiple tests. */
class TestwiseCoverageReportBuilder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.teamscale.client.AntPatternUtils
import com.teamscale.client.FileSystemUtils
import java.util.function.Predicate
import java.util.regex.Pattern
import java.util.stream.Collectors

/**
* Applies ANT include and exclude patterns to paths.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class BashFileSkippingInputStream(input: InputStream) : FilterInputStream(Buffer
* @return The index where the ZIP header starts, or -1 if not found.
*/
private fun findZipHeader(buffer: ByteArray, length: Int) =
(0 .. length - ZIP_HEADER.size)
(0..length - ZIP_HEADER.size)
.firstOrNull {
buffer[it] == ZIP_HEADER[0]
&& buffer[it + 1] == ZIP_HEADER[1]
Expand Down
1 change: 1 addition & 0 deletions teamscale-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
com.teamscale.`java-convention`
com.teamscale.coverage
com.teamscale.publish
kotlin("jvm")
}

publishAs {
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading