|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | + |
| 3 | +<!-- |
| 4 | +We're using not-that-ideal XSLT here as this change, because it must be done over 17+ repos. |
| 5 | +It's a workaround until this gets integrated into a better place, such as datadog-ci or the backend. |
| 6 | +* ticket: https://datadoghq.atlassian.net/browse/APMSP-2610 |
| 7 | +* RFC: https://docs.google.com/document/d/1OaX_h09fCXWmK_1ADrwvilt8Yt5h4WjC7UUAdS3Y3uw/edit?pli=1&tab=t.0#heading=h.tfy5viz7rz2 |
| 8 | +--> |
| 9 | + |
| 10 | +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
| 11 | + |
| 12 | + <!-- Identity transform: copy everything as-is by default --> |
| 13 | + <xsl:template match="@*|node()"> |
| 14 | + <xsl:copy> |
| 15 | + <xsl:apply-templates select="@*|node()"/> |
| 16 | + </xsl:copy> |
| 17 | + </xsl:template> |
| 18 | + |
| 19 | + <!-- For testcase elements missing dd_tags[test.final_status] inside their properties block --> |
| 20 | + <xsl:template match="testcase[not(properties/property[@name='dd_tags[test.final_status]'])]"> |
| 21 | + <xsl:copy> |
| 22 | + <xsl:apply-templates select="@*"/> |
| 23 | + <xsl:variable name="status"> |
| 24 | + <xsl:choose> |
| 25 | + <xsl:when test="failure or error">fail</xsl:when> |
| 26 | + <xsl:when test="skipped">skip</xsl:when> |
| 27 | + <xsl:otherwise>pass</xsl:otherwise> |
| 28 | + </xsl:choose> |
| 29 | + </xsl:variable> |
| 30 | + <xsl:choose> |
| 31 | + <xsl:when test="properties"> |
| 32 | + <!-- Inject into existing properties block, preserving child order --> |
| 33 | + <xsl:for-each select="node()"> |
| 34 | + <xsl:choose> |
| 35 | + <xsl:when test="self::properties"> |
| 36 | + <properties> |
| 37 | + <xsl:apply-templates select="@*|node()"/> |
| 38 | + <property name="dd_tags[test.final_status]" value="{$status}"/> |
| 39 | + </properties> |
| 40 | + </xsl:when> |
| 41 | + <xsl:otherwise> |
| 42 | + <xsl:apply-templates select="."/> |
| 43 | + </xsl:otherwise> |
| 44 | + </xsl:choose> |
| 45 | + </xsl:for-each> |
| 46 | + </xsl:when> |
| 47 | + <xsl:otherwise> |
| 48 | + <!-- No properties block: create one before other children --> |
| 49 | + <properties> |
| 50 | + <property name="dd_tags[test.final_status]" value="{$status}"/> |
| 51 | + </properties> |
| 52 | + <xsl:apply-templates select="node()"/> |
| 53 | + </xsl:otherwise> |
| 54 | + </xsl:choose> |
| 55 | + </xsl:copy> |
| 56 | + </xsl:template> |
| 57 | + |
| 58 | +</xsl:stylesheet> |
0 commit comments