You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2023/05/24 19:54:06 UTC

[maven-surefire] branch simply-valueof-in-time updated (69f730609 -> 8f1705ac4)

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a change to branch simply-valueof-in-time
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git


    omit 69f730609 [SUREFIRE-2164] Simplify serialization of elapsed time in XML reporter
     new 8f1705ac4 [SUREFIRE-2164] Simplify serialization of elapsed time in StatelessXmlReporter

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (69f730609)
            \
             N -- N -- N   refs/heads/simply-valueof-in-time (8f1705ac4)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:


[maven-surefire] 01/01: [SUREFIRE-2164] Simplify serialization of elapsed time in StatelessXmlReporter

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch simply-valueof-in-time
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit 8f1705ac4d4fb85ae8b2d3e75c13af3fc12e7a10
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Fri May 19 19:18:01 2023 +0200

    [SUREFIRE-2164] Simplify serialization of elapsed time in StatelessXmlReporter
    
    This closes #637
---
 .../surefire/report/StatelessXmlReporter.java      | 57 ++++++++++++----------
 1 file changed, 32 insertions(+), 25 deletions(-)

diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
index 7a9a019d9..62299da4e 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
@@ -48,42 +48,45 @@ import static org.apache.maven.plugin.surefire.report.ReportEntryType.SKIPPED;
 import static org.apache.maven.plugin.surefire.report.ReportEntryType.SUCCESS;
 import static org.apache.maven.surefire.shared.utils.StringUtils.isBlank;
 
-@SuppressWarnings({"javadoc", "checkstyle:javadoctype"})
 // CHECKSTYLE_OFF: LineLength
-/*
+/**
  * XML format reporter writing to <code>TEST-<i>reportName</i>[-<i>suffix</i>].xml</code> file like written and read
  * by Ant's <a href="http://ant.apache.org/manual/Tasks/junit.html"><code>&lt;junit&gt;</code></a> and
  * <a href="http://ant.apache.org/manual/Tasks/junitreport.html"><code>&lt;junitreport&gt;</code></a> tasks,
  * then supported by many tools like CI servers.
  * <br>
- * <pre>&lt;?xml version="1.0" encoding="UTF-8"?>
- * &lt;testsuite name="<i>suite name</i>" [group="<i>group</i>"] tests="<i>0</i>" failures="<i>0</i>" errors="<i>0</i>" skipped="<i>0</i>" time="<i>0,###.###</i>">
- *  &lt;properties>
- *    &lt;property name="<i>name</i>" value="<i>value</i>"/>
+ * <pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
+ * &lt;testsuite name="<i>suite name</i>" [group="<i>group</i>"] tests="<i>0</i>" failures="<i>0</i>" errors="<i>0</i>" skipped="<i>0</i>" time="<i>{float}</i>"&gt;
+ *  &lt;properties&gt;
+ *    &lt;property name="<i>name</i>" value="<i>value</i>"/&gt;
  *    [...]
- *  &lt;/properties>
- *  &lt;testcase time="<i>0,###.###</i>" name="<i>test name</i> [classname="<i>class name</i>"] [group="<i>group</i>"]"/>
- *  &lt;testcase time="<i>0,###.###</i>" name="<i>test name</i> [classname="<i>class name</i>"] [group="<i>group</i>"]">
- *    &lt;<b>error</b> message="<i>message</i>" type="<i>exception class name</i>"><i>stacktrace</i>&lt;/error>
- *    &lt;system-out><i>system out content (present only if not empty)</i>&lt;/system-out>
- *    &lt;system-err><i>system err content (present only if not empty)</i>&lt;/system-err>
- *  &lt;/testcase>
- *  &lt;testcase time="<i>0,###.###</i>" name="<i>test name</i> [classname="<i>class name</i>"] [group="<i>group</i>"]">
- *    &lt;<b>failure</b> message="<i>message</i>" type="<i>exception class name</i>"><i>stacktrace</i>&lt;/failure>
- *    &lt;system-out><i>system out content (present only if not empty)</i>&lt;/system-out>
- *    &lt;system-err><i>system err content (present only if not empty)</i>&lt;/system-err>
- *  &lt;/testcase>
- *  &lt;testcase time="<i>0,###.###</i>" name="<i>test name</i> [classname="<i>class name</i>"] [group="<i>group</i>"]">
- *    &lt;<b>skipped</b>/>
- *  &lt;/testcase>
+ *  &lt;/properties&gt;
+ *  &lt;testcase time="<i>{float}</i>" name="<i>test name</i> [classname="<i>class name</i>"] [group="<i>group</i>"]"/&gt;
+ *  &lt;testcase time="<i>{float}</i>" name="<i>test name</i> [classname="<i>class name</i>"] [group="<i>group</i>"]"&gt;
+ *    &lt;<b>error</b> message="<i>message</i>" type="<i>exception class name</i>"&gt;<i>stacktrace</i>&lt;/error&gt;
+ *    &lt;system-out&gt;<i>system out content (present only if not empty)</i>&lt;/system-out&gt;
+ *    &lt;system-err&gt;<i>system err content (present only if not empty)</i>&lt;/system-err&gt;
+ *  &lt;/testcase&gt;
+ *  &lt;testcase time="<i>{float}</i>" name="<i>test name</i> [classname="<i>class name</i>"] [group="<i>group</i>"]"&gt;
+ *    &lt;<b>failure</b> message="<i>message</i>" type="<i>exception class name</i>"&gt;<i>stacktrace</i>&lt;/failure&gt;
+ *    &lt;system-out&gt;<i>system out content (present only if not empty)</i>&lt;/system-out&gt;
+ *    &lt;system-err&gt;<i>system err content (present only if not empty)</i>&lt;/system-err&gt;
+ *  &lt;/testcase&gt;
+ *  &lt;testcase time="<i>{float}</i>" name="<i>test name</i> [classname="<i>class name</i>"] [group="<i>group</i>"]"&gt;
+ *    &lt;<b>skipped</b>/&gt;
+ *  &lt;/testcase&gt;
  *  [...]</pre>
  *
  * @author Kristian Rosenvold
- * @see <a href="http://wiki.apache.org/ant/Proposals/EnhancedTestReports">Ant's format enhancement proposal</a>
+ * @see <a href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=115528872">Ant's format enhancement proposal</a>
  *      (not yet implemented by Ant 1.8.2)
+ * @see <a href="https://github.com/apache/ant/blob/6f68fbdefad521741b37304cfdfc6d8646cf1839/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java">Ant's <code>XMLJUnitResultFormatter</code></a>
  */
-// todo this is no more stateless due to existence of testClassMethodRunHistoryMap since of 2.19.
+@SuppressWarnings({"javadoc", "checkstyle:javadoctype"})
+// TODO this is no more stateless due to existence of testClassMethodRunHistoryMap since of 2.19.
 public class StatelessXmlReporter implements StatelessReportEventListener<WrappedReportEntry, TestSetStats> {
+    private static final float ONE_SECOND = 1000.0f;
+
     private static final String XML_INDENT = "  ";
 
     private static final String XML_NL = "\n";
@@ -387,7 +390,9 @@ public class StatelessXmlReporter implements StatelessReportEventListener<Wrappe
             ppw.addAttribute("classname", extraEscapeAttribute(className));
         }
 
-        ppw.addAttribute("time", report.elapsedTimeAsString());
+        if (report.getElapsed() != null) {
+            ppw.addAttribute("time", String.valueOf(report.getElapsed() / ONE_SECOND));
+        }
     }
 
     private void createTestSuiteElement(XMLWriter ppw, WrappedReportEntry report, TestSetStats testSetStats)
@@ -407,7 +412,9 @@ public class StatelessXmlReporter implements StatelessReportEventListener<Wrappe
             ppw.addAttribute("group", report.getGroup());
         }
 
-        ppw.addAttribute("time", report.elapsedTimeAsString());
+        if (report.getElapsed() != null) {
+            ppw.addAttribute("time", String.valueOf(report.getElapsed() / ONE_SECOND));
+        }
 
         ppw.addAttribute("tests", String.valueOf(testSetStats.getCompletedCount()));