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/22 16:28:13 UTC
[maven-surefire] branch backport updated (b671b1cce -> e992a374e)
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a change to branch backport
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
discard b671b1cce Simplify XML time value parsing
new e992a374e Use typographically correct en dash approximations
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 (b671b1cce)
\
N -- N -- N refs/heads/backport (e992a374e)
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:
.../org/apache/maven/plugins/surefire/report/TestSuiteXmlParser.java | 2 ++
1 file changed, 2 insertions(+)
[maven-surefire] 01/01: Use typographically correct en dash approximations
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch backport
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit e992a374e3ed2a1076f4e7c110475871538a3781
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Fri May 19 21:25:19 2023 +0200
Use typographically correct en dash approximations
https://en.wikipedia.org/wiki/Dash#Approximating_the_em_dash_with_two_or_three_hyphens
---
.../surefire/report/TestSuiteXmlParser.java | 33 ++++++++--------------
1 file changed, 12 insertions(+), 21 deletions(-)
diff --git a/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/TestSuiteXmlParser.java b/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/TestSuiteXmlParser.java
index 83ccc0619..95b31623b 100644
--- a/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/TestSuiteXmlParser.java
+++ b/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/TestSuiteXmlParser.java
@@ -26,8 +26,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
-import java.text.NumberFormat;
-import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -40,15 +38,12 @@ import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import static java.nio.charset.StandardCharsets.UTF_8;
-import static java.util.Locale.ENGLISH;
import static org.apache.maven.shared.utils.StringUtils.isBlank;
/**
*
*/
public final class TestSuiteXmlParser extends DefaultHandler {
- private final NumberFormat numberFormat = NumberFormat.getInstance(ENGLISH);
-
private final ConsoleLogger consoleLogger;
private ReportTestSuite defaultSuite;
@@ -111,13 +106,11 @@ public final class TestSuiteXmlParser extends DefaultHandler {
case "testsuite":
defaultSuite = new ReportTestSuite();
currentSuite = defaultSuite;
-
- try {
- Number time = numberFormat.parse(attributes.getValue("time"));
-
- defaultSuite.setTimeElapsed(time.floatValue());
- } catch (NullPointerException e) {
- consoleLogger.error("WARNING: no time attribute found on testsuite element");
+ String timeStr = attributes.getValue("time");
+ if (timeStr != null) {
+ defaultSuite.setTimeElapsed(Float.parseFloat(timeStr));
+ } else {
+ consoleLogger.warning("No time attribute found on testsuite element");
}
final String name = attributes.getValue("name");
@@ -149,13 +142,12 @@ public final class TestSuiteXmlParser extends DefaultHandler {
}
}
- String timeAsString = attributes.getValue("time");
- Number time = isBlank(timeAsString) ? 0 : numberFormat.parse(timeAsString);
+ timeStr = attributes.getValue("time");
testCase.setFullClassName(currentSuite.getFullClassName())
.setClassName(currentSuite.getName())
.setFullName(currentSuite.getFullClassName() + "." + testCase.getName())
- .setTime(time.floatValue());
+ .setTime(timeStr != null ? Float.parseFloat(timeStr) : 0.0f);
if (currentSuite != defaultSuite) {
currentSuite.setTimeElapsed(testCase.getTime() + currentSuite.getTimeElapsed());
@@ -184,8 +176,8 @@ public final class TestSuiteXmlParser extends DefaultHandler {
default:
break;
}
- } catch (ParseException e) {
- throw new SAXException(e.getMessage(), e);
+ } catch (NumberFormatException e) {
+ throw new SAXException("Failed to parse time value", e);
}
}
}
@@ -206,10 +198,9 @@ public final class TestSuiteXmlParser extends DefaultHandler {
break;
case "time":
try {
- defaultSuite.setTimeElapsed(
- numberFormat.parse(currentElement.toString()).floatValue());
- } catch (ParseException e) {
- throw new SAXException(e.getMessage(), e);
+ defaultSuite.setTimeElapsed(Float.parseFloat(currentElement.toString()));
+ } catch (NumberFormatException e) {
+ throw new SAXException("Failed to parse time value", e);
}
break;
default: