Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS-41980 Handle nested jars for converter #663

Merged
merged 3 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -40,29 +40,29 @@
}

/** Converts one .exec binary coverage file to XML. */
public void runJaCoCoReportGeneration() throws IOException, AgentOptionParseException {
List<File> jacocoExecutionDataList = ReportUtils
.listFiles(ETestArtifactFormat.JACOCO, arguments.getInputFiles());

ExecFileLoader loader = new ExecFileLoader();
for (File jacocoExecutionData : jacocoExecutionDataList) {
loader.load(jacocoExecutionData);
}

SessionInfo sessionInfo = loader.getSessionInfoStore().getMerged("merged");
ExecutionDataStore executionDataStore = loader.getExecutionDataStore();

Logger logger = LoggingUtils.getLogger(this);
JaCoCoXmlReportGenerator generator = new JaCoCoXmlReportGenerator(arguments.getClassDirectoriesOrZips(),
getWildcardIncludeExcludeFilter(), arguments.getDuplicateClassFileBehavior(), arguments.shouldIgnoreUncoveredClasses,
wrap(logger));

try (Benchmark benchmark = new Benchmark("Generating the XML report")) {
generator.convert(new Dump(sessionInfo, executionDataStore), Paths.get(arguments.outputFile).toFile());
} catch (EmptyReportException e) {
logger.warn("Converted report was emtpy.", e);
logger.warn("Converted report was empty.", e);
}
}

Check warning on line 65 in agent/src/main/java/com/teamscale/jacoco/agent/convert/Converter.java

View check run for this annotation

cqse.teamscale.io / teamscale-test-gaps

agent/src/main/java/com/teamscale/jacoco/agent/convert/Converter.java#L43-L65

[Test Gap] Changed method `runJaCoCoReportGeneration` has not been tested. https://cqse.teamscale.io/metrics/code/teamscale-jacoco-agent/agent%2Fsrc%2Fmain%2Fjava%2Fcom%2Fteamscale%2Fjacoco%2Fagent%2Fconvert%2FConverter.java?t=ts%2F41980_closed_stream%3AHEAD&selection=char-1592-2678

/** Converts one .exec binary coverage file, test details and test execution files to JSON testwise coverage. */
public void runTestwiseCoverageReportGeneration() throws IOException, AgentOptionParseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,12 @@
* and added wrapping [BashFileSkippingInputStream].
*/
@Throws(IOException::class)
protected open fun analyzeJar(input: InputStream, location: String): Int {
ZipInputStream(BashFileSkippingInputStream(input)).use { zip ->
return generateSequence { zip.nextEntry(location) }
val zip = ZipInputStream(BashFileSkippingInputStream(input))
return generateSequence { zip.nextEntry(location) }
.map { entry -> analyzeAll(zip, "$location@${entry.name}") }
.sum()
}
}

Check warning on line 76 in report-generator/src/main/kotlin/com/teamscale/report/jacoco/FilteringAnalyzer.kt

View check run for this annotation

cqse.teamscale.io / teamscale-test-gaps

report-generator/src/main/kotlin/com/teamscale/report/jacoco/FilteringAnalyzer.kt#L71-L76

[Test Gap] Changed method `analyzeJar` has not been tested. https://cqse.teamscale.io/metrics/code/teamscale-jacoco-agent/report-generator%2Fsrc%2Fmain%2Fkotlin%2Fcom%2Fteamscale%2Freport%2Fjacoco%2FFilteringAnalyzer.kt?t=ts%2F41980_closed_stream%3AHEAD&selection=char-2693-2952

/** Copied from [org.jacoco.core.analysis.Analyzer.nextEntry]. */
@Throws(IOException::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ class BashFileSkippingInputStream(input: InputStream) : FilterInputStream(Buffer
`in`.mark(BUFFER_SIZE)
bytesRead = `in`.read(buffer, 0, BUFFER_SIZE)
}

throw IOException("ZIP header not found in the input stream.")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the version before the Kotlin conversion we didn't throw an exception 🤷‍♀️

}

/**
Expand Down
Loading