Skip to content

Commit

Permalink
[JENKINS-26227] xUnit plugin doesn't use OS culture when reads time v…
Browse files Browse the repository at this point in the history
…alues in xUnit.net output

To be aware from OS culture the junit-time function converts input from any type to string, replace comma with a dot and use its double value to format millisend time to the correct JUnit format.
  • Loading branch information
nfalco79 committed May 20, 2018
1 parent c9cecd5 commit 850a7bb
Show file tree
Hide file tree
Showing 19 changed files with 367 additions and 253 deletions.
Expand Up @@ -27,10 +27,17 @@ THE SOFTWARE.
<xsl:decimal-format decimal-separator="." grouping-separator=","/>

<xsl:function name="xunit:junit-time" as="xs:string">
<xsl:param name="value" as="xs:double?" />
<xsl:param name="value" as="xs:anyAtomicType?" />

<xsl:variable name="time" as="xs:double">
<xsl:value-of select="translate(string($value),',','.')" />
<xsl:choose>
<xsl:when test="$value instance of xs:double">
<xsl:value-of select="$value" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="translate(string($value), ',', '.')" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="format-number($time, '0.000')" />
</xsl:function>
Expand Down
Expand Up @@ -27,10 +27,17 @@ THE SOFTWARE.
<xsl:decimal-format decimal-separator="." grouping-separator=","/>

<xsl:function name="xunit:junit-time" as="xs:string">
<xsl:param name="value" as="xs:double?" />
<xsl:param name="value" as="xs:anyAtomicType?" />

<xsl:variable name="time" as="xs:double">
<xsl:value-of select="translate(string($value),',','.')" />
<xsl:choose>
<xsl:when test="$value instance of xs:double">
<xsl:value-of select="$value" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="translate(string($value), ',', '.')" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="format-number($time, '0.000')" />
</xsl:function>
Expand Down
Expand Up @@ -27,10 +27,17 @@ THE SOFTWARE.
<xsl:decimal-format decimal-separator="." grouping-separator=","/>

<xsl:function name="xunit:junit-time" as="xs:string">
<xsl:param name="value" as="xs:double?" />
<xsl:param name="value" as="xs:anyAtomicType?" />

<xsl:variable name="time" as="xs:double">
<xsl:value-of select="translate(string($value),',','.')" />
<xsl:choose>
<xsl:when test="$value instance of xs:double">
<xsl:value-of select="$value" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="translate(string($value), ',', '.')" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="format-number($time, '0.000')" />
</xsl:function>
Expand Down
Expand Up @@ -29,10 +29,17 @@ THE SOFTWARE.
<xsl:decimal-format decimal-separator="." grouping-separator=","/>

<xsl:function name="xunit:junit-time" as="xs:string">
<xsl:param name="value" as="xs:double?" />
<xsl:param name="value" as="xs:anyAtomicType?" />

<xsl:variable name="time" as="xs:double">
<xsl:value-of select="translate(string($value),',','.')" />
<xsl:choose>
<xsl:when test="$value instance of xs:double">
<xsl:value-of select="$value" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="translate(string($value), ',', '.')" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="format-number($time, '0.000')" />
</xsl:function>
Expand Down
Expand Up @@ -26,11 +26,18 @@ THE SOFTWARE.
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:decimal-format decimal-separator="." grouping-separator=","/>

<xsl:function name="xunit:junit-time" as="xs:string">
<xsl:param name="value" as="xs:double?" />
<xsl:function name="xunit:junit-time" as="xs:string">
<xsl:param name="value" as="xs:anyAtomicType?" />

<xsl:variable name="time" as="xs:double">
<xsl:value-of select="translate(string($value),',','.')" />
<xsl:choose>
<xsl:when test="$value instance of xs:double">
<xsl:value-of select="$value" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="translate(string($value), ',', '.')" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="format-number($time, '0.000')" />
</xsl:function>
Expand Down
Expand Up @@ -27,10 +27,17 @@ THE SOFTWARE.
<xsl:decimal-format decimal-separator="." grouping-separator=","/>

<xsl:function name="xunit:junit-time" as="xs:string">
<xsl:param name="value" as="xs:double?" />
<xsl:param name="value" as="xs:anyAtomicType?" />

<xsl:variable name="time" as="xs:double">
<xsl:value-of select="translate(string($value),',','.')" />
<xsl:choose>
<xsl:when test="$value instance of xs:double">
<xsl:value-of select="$value" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="translate(string($value), ',', '.')" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="format-number($time, '0.000')" />
</xsl:function>
Expand Down
@@ -1,27 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/*******************************************************************************
* Copyright (c) 2009 Thales Corporate Services SAS *
* Author : Gregory Boissinot *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy *
* of this software and associated documentation files (the "Software"), to deal*
* in the Software without restriction, including without limitation the rights *
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,*
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN *
* THE SOFTWARE. *
*******************************************************************************/
The MIT License (MIT)
Copyright (c) 2018, Gregory Boissinot, Falco Nikolas
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xunit="http://www.xunit.org">

Expand All @@ -35,10 +34,17 @@
</xsl:function>

<xsl:function name="xunit:junit-time" as="xs:string">
<xsl:param name="value" as="xs:string?" />
<xsl:param name="value" as="xs:anyAtomicType?" />

<xsl:variable name="time" as="xs:double">
<xsl:value-of select="translate($value,',','.')" />
<xsl:choose>
<xsl:when test="$value instance of xs:double">
<xsl:value-of select="$value" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="translate(string($value), ',', '.')" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="format-number($time, '0.000')" />
</xsl:function>
Expand Down
Expand Up @@ -28,10 +28,17 @@ THE SOFTWARE.
<xsl:decimal-format decimal-separator="." grouping-separator=","/>

<xsl:function name="xunit:junit-time" as="xs:string">
<xsl:param name="value" as="xs:double?" />
<xsl:param name="value" as="xs:anyAtomicType?" />

<xsl:variable name="time" as="xs:double">
<xsl:value-of select="translate(string($value),',','.')" />
<xsl:choose>
<xsl:when test="$value instance of xs:double">
<xsl:value-of select="$value" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="translate(string($value), ',', '.')" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="format-number($time, '0.000')" />
</xsl:function>
Expand Down

0 comments on commit 850a7bb

Please sign in to comment.