CTest2JUnit.xsl 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  2. <xsl:output method="xml" indent="yes"/>
  3. <xsl:template match="/Site">
  4. <xsl:variable name="Name"><xsl:value-of select="@Name"/></xsl:variable>
  5. <xsl:variable name="Hostname"><xsl:value-of select="@Hostname"/></xsl:variable>
  6. <xsl:variable name="TestCount"><xsl:value-of select="count(//TestList/Test)"/> </xsl:variable>
  7. <xsl:variable name="ErrorCount"><xsl:value-of select="count(//TestList/Test[@Status='error'])"/> </xsl:variable>
  8. <xsl:variable name="FailureCount"><xsl:value-of select="count(//Testing/Test[@Status='failed'])"/> </xsl:variable>
  9. <testsuite name="{$Name}" hostname="{$Hostname}" errors="0" failures="{$FailureCount}" tests="{$TestCount}">
  10. <xsl:variable name="BuildName"><xsl:value-of select="@BuildName"/></xsl:variable>
  11. <xsl:variable name="BuildStamp"><xsl:value-of select="@BuildStamp"/></xsl:variable>
  12. <xsl:variable name="Generator"><xsl:value-of select="@Generator"/></xsl:variable>
  13. <xsl:variable name="CompilerName"><xsl:value-of select="@CompilerName"/></xsl:variable>
  14. <xsl:variable name="OSName"><xsl:value-of select="@OSName"/></xsl:variable>
  15. <xsl:variable name="OSRelease"><xsl:value-of select="@OSRelease"/></xsl:variable>
  16. <xsl:variable name="OSVersion"><xsl:value-of select="@OSVersion"/></xsl:variable>
  17. <xsl:variable name="OSPlatform"><xsl:value-of select="@OSPlatform"/></xsl:variable>
  18. <xsl:variable name="Is64Bits"><xsl:value-of select="@Is64Bits"/></xsl:variable>
  19. <xsl:variable name="VendorString"><xsl:value-of select="@VendorString"/></xsl:variable>
  20. <xsl:variable name="VendorID"><xsl:value-of select="@VendorID"/></xsl:variable>
  21. <xsl:variable name="FamilyID"><xsl:value-of select="@FamilyID"/></xsl:variable>
  22. <xsl:variable name="ModelID"><xsl:value-of select="@ModelID"/></xsl:variable>
  23. <xsl:variable name="ProcessorCacheSize"><xsl:value-of select="@ProcessorCacheSize"/></xsl:variable>
  24. <xsl:variable name="NumberOfLogicalCPU"><xsl:value-of select="@NumberOfLogicalCPU"/></xsl:variable>
  25. <xsl:variable name="NumberOfPhysicalCPU"><xsl:value-of select="@NumberOfPhysicalCPU"/></xsl:variable>
  26. <xsl:variable name="TotalVirtualMemory"><xsl:value-of select="@TotalVirtualMemory"/></xsl:variable>
  27. <xsl:variable name="TotalPhysicalMemory"><xsl:value-of select="@TotalPhysicalMemory"/></xsl:variable>
  28. <xsl:variable name="LogicalProcessorsPerPhysical"><xsl:value-of select="@LogicalProcessorsPerPhysical"/></xsl:variable>
  29. <xsl:variable name="ProcessorClockFrequency"><xsl:value-of select="@ProcessorClockFrequency"/></xsl:variable>
  30. <properties>
  31. <property name="BuildName" value="{$BuildName}" />
  32. <property name="BuildStamp" value="{$BuildStamp}" />
  33. <property name="Name" value="{$Name}" />
  34. <property name="Generator" value="{$Generator}" />
  35. <property name="CompilerName" value="{$CompilerName}" />
  36. <property name="OSName" value="{$OSName}" />
  37. <property name="Hostname" value="{$Hostname}" />
  38. <property name="OSRelease" value="{$OSRelease}" />
  39. <property name="OSVersion" value="{$OSVersion}" />
  40. <property name="OSPlatform" value="{$OSPlatform}" />
  41. <property name="Is64Bits" value="{$Is64Bits}" />
  42. <property name="VendorString" value="{$VendorString}" />
  43. <property name="VendorID" value="{$VendorID}" />
  44. <property name="FamilyID" value="{$FamilyID}" />
  45. <property name="ModelID" value="{$ModelID}" />
  46. <property name="ProcessorCacheSize" value="{$ProcessorCacheSize}" />
  47. <property name="NumberOfLogicalCPU" value="{$NumberOfLogicalCPU}" />
  48. <property name="NumberOfPhysicalCPU" value="{$NumberOfPhysicalCPU}" />
  49. <property name="TotalVirtualMemory" value="{$TotalVirtualMemory}" />
  50. <property name="TotalPhysicalMemory" value="{$TotalPhysicalMemory}" />
  51. <property name="LogicalProcessorsPerPhysical" value="{$LogicalProcessorsPerPhysical}" />
  52. <property name="ProcessorClockFrequency" value="{$ProcessorClockFrequency}" />
  53. </properties>
  54. <xsl:apply-templates select="Testing/Test"/>
  55. <system-out>
  56. BuildName: <xsl:value-of select="$BuildName" />
  57. BuildStamp: <xsl:value-of select="$BuildStamp" />
  58. Name: <xsl:value-of select="$Name" />
  59. Generator: <xsl:value-of select="$Generator" />
  60. CompilerName: <xsl:value-of select="$CompilerName" />
  61. OSName: <xsl:value-of select="$OSName" />
  62. Hostname: <xsl:value-of select="$Hostname" />
  63. OSRelease: <xsl:value-of select="$OSRelease" />
  64. OSVersion: <xsl:value-of select="$OSVersion" />
  65. OSPlatform: <xsl:value-of select="$OSPlatform" />
  66. Is64Bits: <xsl:value-of select="$Is64Bits" />
  67. VendorString: <xsl:value-of select="$VendorString" />
  68. VendorID: <xsl:value-of select="$VendorID" />
  69. FamilyID: <xsl:value-of select="$FamilyID" />
  70. ModelID: <xsl:value-of select="$ModelID" />
  71. ProcessorCacheSize: <xsl:value-of select="$ProcessorCacheSize" />
  72. NumberOfLogicalCPU: <xsl:value-of select="$NumberOfLogicalCPU" />
  73. NumberOfPhysicalCPU: <xsl:value-of select="$NumberOfPhysicalCPU" />
  74. TotalVirtualMemory: <xsl:value-of select="$TotalVirtualMemory" />
  75. TotalPhysicalMemory: <xsl:value-of select="$TotalPhysicalMemory" />
  76. LogicalProcessorsPerPhysical: <xsl:value-of select="$LogicalProcessorsPerPhysical" />
  77. ProcessorClockFrequency: <xsl:value-of select="$ProcessorClockFrequency" />
  78. </system-out>
  79. </testsuite>
  80. </xsl:template>
  81. <xsl:template match="Testing/Test">
  82. <xsl:variable name="testcasename"><xsl:value-of select= "Name"/></xsl:variable>
  83. <xsl:variable name="testclassname"><xsl:value-of select= " concat('this', substring(Path,2))"/></xsl:variable>
  84. <xsl:variable name="exectime">
  85. <xsl:for-each select="Results/NamedMeasurement">
  86. <xsl:if test="@name = 'Execution Time'">
  87. <xsl:value-of select="."/>
  88. </xsl:if>
  89. </xsl:for-each>
  90. </xsl:variable>
  91. <testcase name="{$testcasename}" classname="{$testclassname}" time="{$exectime}">
  92. <xsl:if test="@Status = 'passed'">
  93. </xsl:if>
  94. <xsl:if test="@Status = 'failed'">
  95. <xsl:variable name="failtype">
  96. <xsl:for-each select="Results/NamedMeasurement">
  97. <xsl:if test="@name = 'Exit Code'">
  98. <xsl:value-of select="."/>
  99. </xsl:if>
  100. </xsl:for-each>
  101. </xsl:variable>
  102. <xsl:variable name="failcode">
  103. <xsl:for-each select="Results/NamedMeasurement">
  104. <xsl:if test="@name = 'Exit Value'">
  105. <xsl:value-of select="."/>
  106. </xsl:if>
  107. </xsl:for-each>
  108. </xsl:variable>
  109. <failure message="{$failtype} ({$failcode})"><xsl:value-of select="Results/Measurement/Value/text()" /></failure>
  110. </xsl:if>
  111. <xsl:if test="@Status = 'notrun'">
  112. <skipped><xsl:value-of select="Results/Measurement/Value/text()" /></skipped>
  113. </xsl:if>
  114. </testcase>
  115. </xsl:template>
  116. </xsl:stylesheet>