File tree 3 files changed +1850
-1
lines changed
main/java/edu/hm/hafner/coverage/parser
java/edu/hm/hafner/coverage/parser
resources/edu/hm/hafner/coverage/parser/cobertura
3 files changed +1850
-1
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,8 @@ public class CoberturaParser extends CoverageParser {
41
41
private static final Pattern BRANCH_PATTERN = Pattern .compile (".*\\ ((?<covered>\\ d+)/(?<total>\\ d+)\\ )" );
42
42
private static final PathUtil PATH_UTIL = new PathUtil ();
43
43
44
+ private static final String DETERMINISTIC_PATH_PREFIX = "/_/" ;
45
+
44
46
private static final Coverage DEFAULT_BRANCH_COVERAGE = new CoverageBuilder (Metric .BRANCH ).withCovered (2 ).withMissed (0 ).build ();
45
47
private static final Coverage LINE_COVERED = new CoverageBuilder (Metric .LINE ).withCovered (1 ).withMissed (0 ).build ();
46
48
private static final Coverage LINE_MISSED = new CoverageBuilder (Metric .LINE ).withCovered (0 ).withMissed (1 ).build ();
@@ -141,7 +143,8 @@ else if (event.isEndElement()) {
141
143
142
144
private FileNode createFileNode (final StartElement element , final PackageNode packageNode ) {
143
145
var fileName = getValueOf (element , FILE_NAME );
144
- var path = getTreeStringBuilder ().intern (PATH_UTIL .getRelativePath (fileName ));
146
+ var relativePath = StringUtils .removeStart (PATH_UTIL .getRelativePath (fileName ), DETERMINISTIC_PATH_PREFIX );
147
+ var path = getTreeStringBuilder ().intern (relativePath );
145
148
146
149
return packageNode .findOrCreateFileNode (getFileName (fileName ), path );
147
150
}
Original file line number Diff line number Diff line change @@ -38,6 +38,24 @@ protected String getFolder() {
38
38
return "cobertura" ;
39
39
}
40
40
41
+ @ Test
42
+ @ Issue ("JENKINS-73635" )
43
+ void shouldRemovePrefixOfDeterministicCoverageReport () {
44
+ var root = readReport ("c#-cobertura.xml" );
45
+
46
+ assertThat (root .getAllFileNodes ()).hasSize (20 ).map (FileNode ::getRelativePath )
47
+ .allSatisfy (
48
+ file -> assertThat (file )
49
+ .doesNotStartWith ("/_/" )
50
+ .startsWith ("Lib.LicenseScanner/" ));
51
+
52
+ assertThat (root .getAllFileNodes ()).hasSize (20 )
53
+ .first ().satisfies (
54
+ file -> assertThat (file )
55
+ .hasName ("IssueKeys.cs" )
56
+ .hasRelativePath ("Lib.LicenseScanner/IssueKeys.cs" ));
57
+ }
58
+
41
59
@ Test
42
60
@ Issue ("JENKINS-73325" )
43
61
void shouldUseFullPathWhenParsingFileNodes () {
You can’t perform that action at this time.
0 commit comments