Skip to content

Commit

Permalink
Merge branch 'bom' into dependabot/maven/testcontainers.version-1.19.4
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Jan 26, 2024
2 parents a263d2c + 6a09e1a commit ddab09c
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 12 deletions.
2 changes: 1 addition & 1 deletion plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>analysis-pom</artifactId>
<version>6.17.0</version>
<version>7.0.0</version>
<relativePath />
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* @author Florian Orendi
*/
public class ColorProvider {

/**
* Default color that is provided if no color is found in order to guarantee a proper colorization.
*/
Expand Down Expand Up @@ -167,11 +166,8 @@ public DisplayColors getBlendedDisplayColors(final double weightFirst, final dou

/**
* Wraps the fill color and the line color that should be used in order to visualize coverage values.
*
* @author Florian Orendi
*/
public static class DisplayColors {

private final Color lineColor;
private final Color fillColor;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package io.jenkins.plugins.coverage.metrics.steps;

import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Optional;

import org.apache.commons.io.input.BOMInputStream;

import edu.hm.hafner.coverage.CoverageParser;
import edu.hm.hafner.coverage.CoverageParser.ProcessingMode;
import edu.hm.hafner.coverage.ModuleNode;
Expand Down Expand Up @@ -55,9 +57,10 @@ public CoverageReportScanner(final Parser parser, final String filePattern, fina

@Override
protected Optional<ModuleNode> processFile(final Path file, final Charset charset, final FilteredLog log) {
try {
CoverageParser coverageParser = parser.createParser(processingMode);
ModuleNode node = coverageParser.parse(Files.newBufferedReader(file, charset), log);
CoverageParser coverageParser = parser.createParser(processingMode);
try (var inputStream = BOMInputStream.builder().setFile(file.toFile()).setCharset(charset).get();
var reader = new InputStreamReader(inputStream, charset)) {
ModuleNode node = coverageParser.parse(reader, log);
log.logInfo("Successfully parsed file '%s'", PATH_UTIL.getAbsolutePath(file));
node.aggregateValues().forEach(v -> log.logInfo("%s", v));
return Optional.of(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* @author Florian Orendi
*/
public abstract class AbstractModifiedFilesCoverageTest extends AbstractCoverageTest {

private static final String TEST_FILE_MODIFIED = "Test1.java";
private static final String TEST_FILE_NOT_MODIFIED = "Main.java";
private static final String TEST_FILE_MODIFIED_PATH = "test/example/" + TEST_FILE_MODIFIED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import org.junitpioneer.jupiter.Issue;

import edu.hm.hafner.coverage.Coverage;
import edu.hm.hafner.coverage.Coverage.CoverageBuilder;
Expand Down Expand Up @@ -367,8 +368,7 @@ private void verifyForOneCoberturaAndOneJacoco(final ParameterizedJob<?, ?> proj
"-> extracting...",
"-> done",
"Finished coverage processing - adding the action to the build...");
assertThat(log.getErrorMessages()).contains("Errors while recording code coverage:",
"Errors during source path resolving:",
assertThat(log.getErrorMessages()).contains(
"Errors while resolving source files on agent:",
"Removing non-workspace source directory '/Users/leobalter/dev/testing/solutions/3' - it has not been approved in Jenkins' global configuration.",
"- Source file 'edu/hm/hafner/analysis/parser/PerlCriticParser.java' not found",
Expand Down Expand Up @@ -399,6 +399,10 @@ void shouldRecordOneOpenCoverResultInFreestyleJob() {

Run<?, ?> build = buildSuccessfully(project);

verifyOpenCoverResults(build);
}

private void verifyOpenCoverResults(final Run<?, ?> build) {
CoverageBuildAction coverageResult = build.getAction(CoverageBuildAction.class);
assertThat(coverageResult.getAllValues(Baseline.PROJECT))
.filteredOn(Value::getMetric, Metric.LINE)
Expand All @@ -409,6 +413,21 @@ void shouldRecordOneOpenCoverResultInFreestyleJob() {
});
}

@Test @Issue("JENKINS-72595")
void shouldGracefullyHandleBomEncodedFiles() {
assumeThatTestIsRunningOnUnix();

var fileName = "opencover-with-bom.xml";
WorkflowJob job = createPipelineWithWorkspaceFiles(fileName);

setPipelineScript(job,
"recordCoverage tools: [[parser: 'OPENCOVER', pattern: '" + fileName + "']]");

Run<?, ?> build = buildSuccessfully(job);

verifyOpenCoverResults(build);
}

@Test
void shouldRecordOneNUnitResultInFreestyleJob() {
FreeStyleProject project = createFreestyleJob(Parser.NUNIT, "nunit.xml");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<CoverageSession>
<Summary numSequencePoints="15" visitedSequencePoints="9" numBranchPoints="6" visitedBranchPoints="3" sequenceCoverage="60" branchCoverage="50" maxCyclomaticComplexity="6" minCyclomaticComplexity="6" visitedClasses="1" numClasses="1" visitedMethods="1" numMethods="1" />
<Modules>
<Module hash="31750BAB-054A-4C4B-8763-D76F95F0353A">
<ModulePath>ClassLibrary.dll</ModulePath>
<ModuleTime>2019-12-13T01:36:13</ModuleTime>
<ModuleName>ClassLibrary</ModuleName>
<Files>
<File uid="1" fullPath="[PLACEHOLDER]" />
</Files>
<Classes>
<Class>
<Summary numSequencePoints="15" visitedSequencePoints="9" numBranchPoints="6" visitedBranchPoints="3" sequenceCoverage="60" branchCoverage="50" maxCyclomaticComplexity="6" minCyclomaticComplexity="6" visitedClasses="1" numClasses="1" visitedMethods="1" numMethods="1" />
<FullName>ClassLibrary.LibraryClass</FullName>
<Methods>
<Method cyclomaticComplexity="6" nPathComplexity="0" sequenceCoverage="60" branchCoverage="50" isConstructor="False" isGetter="False" isSetter="False" isStatic="True">
<Summary numSequencePoints="15" visitedSequencePoints="9" numBranchPoints="6" visitedBranchPoints="3" sequenceCoverage="60" branchCoverage="50" maxCyclomaticComplexity="6" minCyclomaticComplexity="6" visitedClasses="0" numClasses="0" visitedMethods="1" numMethods="1" />
<MetadataToken />
<Name>System.Int32 ClassLibrary.LibraryClass::Sum(System.Int32,System.Int32)</Name>
<FileRef uid="1" />
<SequencePoints>
<SequencePoint vc="2" uspid="8" ordinal="0" sl="8" sc="1" el="8" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="2" uspid="9" ordinal="1" sl="9" sc="1" el="9" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="2" uspid="10" ordinal="2" sl="10" sc="1" el="10" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="13" ordinal="3" sl="13" sc="1" el="13" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="14" ordinal="4" sl="14" sc="1" el="14" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="16" ordinal="5" sl="16" sc="1" el="16" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="17" ordinal="6" sl="17" sc="1" el="17" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="19" ordinal="7" sl="19" sc="1" el="19" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="20" ordinal="8" sl="20" sc="1" el="20" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="1" uspid="22" ordinal="9" sl="22" sc="1" el="22" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="1" uspid="23" ordinal="10" sl="23" sc="1" el="23" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="1" uspid="25" ordinal="11" sl="25" sc="1" el="25" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="1" uspid="26" ordinal="12" sl="26" sc="1" el="26" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="2" uspid="28" ordinal="13" sl="28" sc="1" el="28" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="2" uspid="29" ordinal="14" sl="29" sc="1" el="29" ec="2" bec="0" bev="0" fileid="1" />
</SequencePoints>
<BranchPoints>
<BranchPoint vc="0" uspid="10" ordinal="1" path="1" offset="8" offsetend="35" sl="10" fileid="1" />
<BranchPoint vc="0" uspid="10" ordinal="2" path="2" offset="8" offsetend="44" sl="10" fileid="1" />
<BranchPoint vc="0" uspid="10" ordinal="3" path="3" offset="8" offsetend="53" sl="10" fileid="1" />
<BranchPoint vc="1" uspid="10" ordinal="4" path="4" offset="8" offsetend="62" sl="10" fileid="1" />
<BranchPoint vc="1" uspid="10" ordinal="5" path="5" offset="8" offsetend="71" sl="10" fileid="1" />
<BranchPoint vc="2" uspid="10" ordinal="0" path="0" offset="8" offsetend="80" sl="10" fileid="1" />
</BranchPoints>
<MethodPoint vc="9" uspid="0" p8:type="SequencePoint" ordinal="0" offset="0" sc="0" sl="8" ec="1" el="29" bec="0" bev="0" fileid="1" xmlns:p8="xsi" />
</Method>
</Methods>
</Class>
</Classes>
</Module>
</Modules>
</CoverageSession>

0 comments on commit ddab09c

Please sign in to comment.