Skip to content

Commit 96c4af7

Browse files
authored
maven-surefire-report-plugin title settings change (#1896)
This change fixes different location (XPath) in test HTML reports as maven-surefire-report-plugin uses different site skin. Signed-off-by: Radek Felcman <[email protected]>
1 parent b4dcd36 commit 96c4af7

File tree

5 files changed

+164
-21
lines changed

5 files changed

+164
-21
lines changed

bundles/nightly/pom.xml

+72-20
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright (c) 2019, 2022 Oracle and/or its affiliates. All rights reserved.
4+
Copyright (c) 2019, 2023 Oracle and/or its affiliates. All rights reserved.
55
66
This program and the accompanying materials are made available under the
77
terms of the Eclipse Public License v. 2.0 which is available at
@@ -72,7 +72,7 @@
7272
<artifactId>maven-antrun-plugin</artifactId>
7373
<executions>
7474
<execution>
75-
<phase>process-resources</phase>
75+
<phase>generate-resources</phase>
7676
<goals>
7777
<goal>run</goal>
7878
</goals>
@@ -113,7 +113,7 @@
113113
<executions>
114114
<execution>
115115
<id>generate-test-summary-html-report</id>
116-
<phase>package</phase>
116+
<phase>generate-resources</phase>
117117
<goals>
118118
<goal>failsafe-report-only</goal>
119119
</goals>
@@ -123,7 +123,30 @@
123123
</reportsDirectories>
124124
<outputDirectory>${project.build.directory}/jpa-test-reports/${project.build.testReports.subdirectory}</outputDirectory>
125125
<outputName>${project.build.testReports.summaryFile}</outputName>
126-
<title>EclipseLink JPA Test - Test Summary (more details on ${env.BUILD_URL} )</title>
126+
<customBundle>${project.basedir}/src/site/custom/surefire-report.properties</customBundle>
127+
</configuration>
128+
</execution>
129+
</executions>
130+
</plugin>
131+
<plugin>
132+
<groupId>org.apache.maven.plugins</groupId>
133+
<artifactId>maven-antrun-plugin</artifactId>
134+
<executions>
135+
<execution>
136+
<id>prepare-nightly-build-dir-test-reports-resources</id>
137+
<phase>generate-resources</phase>
138+
<goals>
139+
<goal>run</goal>
140+
</goals>
141+
<configuration>
142+
<target>
143+
<copy todir="${project.build.directory}${nightlyDir}/Eclipse/css/">
144+
<fileset dir="../../foundation/eclipselink.core.test/target/${project.build.testReports.subdirectory}/css/"/>
145+
</copy>
146+
<copy todir="${project.build.directory}${nightlyDir}/Eclipse/images/">
147+
<fileset dir="../../foundation/eclipselink.core.test/target/${project.build.testReports.subdirectory}/images/"/>
148+
</copy>
149+
</target>
127150
</configuration>
128151
</execution>
129152
</executions>
@@ -134,7 +157,7 @@
134157
<executions>
135158
<execution>
136159
<id>prepare-nightly-build-dir-test-reports</id>
137-
<phase>package</phase>
160+
<phase>generate-resources</phase>
138161
<goals>
139162
<goal>copy</goal>
140163
</goals>
@@ -217,7 +240,7 @@
217240
</execution>
218241
<execution>
219242
<id>prepare-nightly-build-dir-binaries</id>
220-
<phase>package</phase>
243+
<phase>process-resources</phase>
221244
<goals>
222245
<goal>copy</goal>
223246
</goals>
@@ -273,6 +296,31 @@
273296
</execution>
274297
</executions>
275298
</plugin>
299+
<plugin>
300+
<groupId>org.apache.maven.plugins</groupId>
301+
<artifactId>maven-antrun-plugin</artifactId>
302+
<executions>
303+
<execution>
304+
<id>fix-test-reports</id>
305+
<phase>package</phase>
306+
<goals>
307+
<goal>run</goal>
308+
</goals>
309+
<configuration>
310+
<target>
311+
<!-- Fix some non-XML valid sequence in test reports -->
312+
<replace dir="${project.build.directory}${nightlyDir}/Eclipse/">
313+
<include name="**/*.html"/>
314+
<replacefilter>
315+
<replacetoken><![CDATA[&&]]></replacetoken>
316+
<replacevalue><![CDATA[&amp;&amp;]]></replacevalue>
317+
</replacefilter>
318+
</replace>
319+
</target>
320+
</configuration>
321+
</execution>
322+
</executions>
323+
</plugin>
276324
<plugin>
277325
<groupId>org.codehaus.gmaven</groupId>
278326
<artifactId>groovy-maven-plugin</artifactId>
@@ -289,9 +337,10 @@
289337
import javax.xml.xpath.XPathFactory
290338
import javax.xml.parsers.DocumentBuilderFactory
291339
292-
final NO_OF_TESTS_XPATH = "/html/body/div[@id='bodyColumn']/div/section[2]/table/tr[2]/td[1]/text()"
293-
final NO_OF_ERRORS_XPATH = "/html/body/div[@id='bodyColumn']/div/section[2]/table/tr[2]/td[2]/text()"
294-
final NO_OF_FAILURES_XPATH = "/html/body/div[@id='bodyColumn']/div/section[2]/table/tr[2]/td[3]/text()"
340+
final NO_OF_TESTS_XPATH = "/html/body/div[@id='bodyColumn']/div[@id='contentBox']/section[2]/table/tr[2]/td[1]/text()"
341+
final NO_OF_ERRORS_XPATH = "/html/body/div[@id='bodyColumn']/div[@id='contentBox']/section[2]/table/tr[2]/td[2]/text()"
342+
final NO_OF_FAILURES_XPATH = "/html/body/div[@id='bodyColumn']/div[@id='contentBox']/section[2]/table/tr[2]/td[3]/text()"
343+
295344
final OUTPUT_FILE = "ResultSummary.dat"
296345
297346
def resultSummaryFile = new File(properties["nightlyTestReportsDir"] + "/" + OUTPUT_FILE)
@@ -318,18 +367,21 @@
318367
}
319368
File[] files = reportDir.listFiles()
320369
for (File file : files) {
321-
try {
322-
noOfTests = processXml(file.text, NO_OF_TESTS_XPATH)
323-
noOfNewTests = noOfTests
324-
noOfErrors = processXml(file.text, NO_OF_ERRORS_XPATH) +
325-
processXml(file.text, NO_OF_FAILURES_XPATH)
326-
} catch (Exception e) {
327-
log.warn "File: " + file.getName() + " can't be parsed. Result will be marked as a failed test!"
328-
noOfTests = 1
329-
noOfNewTests = 1
330-
noOfErrors = 1
370+
if (file.isFile()) {
371+
try {
372+
noOfTests = processXml(file.text, NO_OF_TESTS_XPATH)
373+
noOfNewTests = noOfTests
374+
noOfErrors = processXml(file.text, NO_OF_ERRORS_XPATH) + processXml(file.text, NO_OF_FAILURES_XPATH)
375+
} catch (Exception e) {
376+
log.warn "Error cause: ${e}"
377+
log.warn "File: " + file.getName() + " can't be parsed. Result will be marked as a failed test!"
378+
noOfTests = 1
379+
noOfNewTests = 1
380+
noOfErrors = 1
381+
}
382+
resultSummaryFile.append file.
383+
getName() + ":" + noOfTests + ":" + noOfNewTests + ":" + noOfErrors + "\n"
331384
}
332-
resultSummaryFile.append file.getName() + ":" + noOfTests + ":" + noOfNewTests + ":" + noOfErrors + "\n"
333385
}
334386
println resultSummaryFile.text
335387
]]>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved.
3+
#
4+
# This program and the accompanying materials are made available under the
5+
# terms of the Eclipse Public License v. 2.0 which is available at
6+
# http://www.eclipse.org/legal/epl-2.0,
7+
# or the Eclipse Distribution License v. 1.0 which is available at
8+
# http://www.eclipse.org/org/documents/edl-v10.php.
9+
#
10+
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
11+
#
12+
13+
report.failsafe.description=EclipseLink JPA Test - Test Summary (more details on ${env.BUILD_URL} )
14+
report.failsafe.name=EclipseLink JPA Test - Test Summary (more details on ${env.BUILD_URL} )
15+
report.failsafe.title=EclipseLink JPA Test - Test Summary (more details on ${env.BUILD_URL} )
16+
report.surefire.description=EclipseLink JPA Test - Test Summary (more details on ${env.BUILD_URL} )
17+
report.surefire.name=EclipseLink JPA Test - Test Summary (more details on ${env.BUILD_URL} )
18+
report.surefire.title=EclipseLink JPA Test - Test Summary (more details on ${env.BUILD_URL} )

pom.xml

+23-1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
<maven.build.timestamp.format>yyyyMMddHHmm</maven.build.timestamp.format>
122122
<build.qualifier>v${maven.build.timestamp}</build.qualifier>
123123
<bundle.version>${project.version}.${build.qualifier}</bundle.version>
124+
<project.build.testReports.settings>test-report-settings/surefire-report.properties</project.build.testReports.settings>
124125
<project.build.testReports.subdirectory>test-reports</project.build.testReports.subdirectory>
125126
<project.build.testReports.summaryFile>test-summary</project.build.testReports.summaryFile>
126127
<project.build.licenceResourceDirectory>${project.build.directory}/license</project.build.licenceResourceDirectory>
@@ -151,6 +152,7 @@
151152
<test.properties.file>${user.home}/${test.derby.properties.file}</test.properties.file>
152153
<test.properties.fileName>${test.derby.properties.file}</test.properties.fileName>
153154
<test.properties.default.directory>${project.build.directory}/test-default-properties</test.properties.default.directory>
155+
<test.report.properties.default.directory>${project.build.directory}/test-report-properties</test.report.properties.default.directory>
154156
<test.database>derby</test.database>
155157
<!--false: to start In-Memory database, true: not start (MySQL, Oracle)-->
156158
<test.skip.in-memory.db>false</test.skip.in-memory.db>
@@ -1436,6 +1438,7 @@
14361438
<descriptors>
14371439
<descriptor>src/main/assembly/common-license.xml</descriptor>
14381440
<descriptor>src/main/assembly/test-defaults.xml</descriptor>
1441+
<descriptor>src/main/assembly/test-report.xml</descriptor>
14391442
<descriptor>src/main/assembly/spotbugs-filter.xml</descriptor>
14401443
</descriptors>
14411444
</configuration>
@@ -1484,6 +1487,25 @@
14841487
</artifactItems>
14851488
</configuration>
14861489
</execution>
1490+
<execution>
1491+
<id>unpack-test-report-properties</id>
1492+
<phase>initialize</phase>
1493+
<goals>
1494+
<goal>unpack</goal>
1495+
</goals>
1496+
<configuration>
1497+
<artifactItems>
1498+
<artifactItem>
1499+
<groupId>${project.groupId}</groupId>
1500+
<artifactId>org.eclipse.persistence.parent</artifactId>
1501+
<version>${project.version}</version>
1502+
<classifier>test-report</classifier>
1503+
<type>zip</type>
1504+
<outputDirectory>${test.report.properties.default.directory}</outputDirectory>
1505+
</artifactItem>
1506+
</artifactItems>
1507+
</configuration>
1508+
</execution>
14871509
<execution>
14881510
<id>unpack-spotbugs-filter</id>
14891511
<phase>initialize</phase>
@@ -1759,7 +1781,7 @@
17591781
</reportsDirectories>
17601782
<outputDirectory>${project.build.directory}/${project.build.testReports.subdirectory}</outputDirectory>
17611783
<outputName>${project.build.testReports.summaryFile}</outputName>
1762-
<title>${project.name} - Test Summary (more details on ${env.BUILD_URL} )</title>
1784+
<customBundle>${test.report.properties.default.directory}/surefire-report.properties</customBundle>
17631785
</configuration>
17641786
</execution>
17651787
</executions>

src/main/assembly/test-report.xml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved.
5+
6+
This program and the accompanying materials are made available under the
7+
terms of the Eclipse Public License v. 2.0 which is available at
8+
http://www.eclipse.org/legal/epl-2.0,
9+
or the Eclipse Distribution License v. 1.0 which is available at
10+
http://www.eclipse.org/org/documents/edl-v10.php.
11+
12+
SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
13+
14+
-->
15+
16+
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
17+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18+
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
19+
<id>test-report</id>
20+
<formats>
21+
<format>zip</format>
22+
</formats>
23+
<includeBaseDirectory>false</includeBaseDirectory>
24+
<fileSets>
25+
<fileSet>
26+
<directory>${project.basedir}/src/site/custom</directory>
27+
<outputDirectory>.</outputDirectory>
28+
<includes>
29+
<include>*.properties</include>
30+
</includes>
31+
</fileSet>
32+
</fileSets>
33+
</assembly>
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved.
3+
#
4+
# This program and the accompanying materials are made available under the
5+
# terms of the Eclipse Public License v. 2.0 which is available at
6+
# http://www.eclipse.org/legal/epl-2.0,
7+
# or the Eclipse Distribution License v. 1.0 which is available at
8+
# http://www.eclipse.org/org/documents/edl-v10.php.
9+
#
10+
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
11+
#
12+
13+
report.failsafe.description=${project.name} - Test Summary (more details on ${env.BUILD_URL} )
14+
report.failsafe.name=${project.name} - Test Summary (more details on ${env.BUILD_URL} )
15+
report.failsafe.title=${project.name} - Test Summary (more details on ${env.BUILD_URL} )
16+
report.surefire.description=${project.name} - Test Summary (more details on ${env.BUILD_URL} )
17+
report.surefire.name=${project.name} - Test Summary (more details on ${env.BUILD_URL} )
18+
report.surefire.title=${project.name} - Test Summary (more details on ${env.BUILD_URL} )

0 commit comments

Comments
 (0)