CTest2JUnit.xsl 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. <testsuite>
  5. <xsl:variable name="BuildName"><xsl:value-of select="@BuildName"/></xsl:variable>
  6. <xsl:variable name="BuildStamp"><xsl:value-of select="@BuildStamp"/></xsl:variable>
  7. <xsl:variable name="Name"><xsl:value-of select="@Name"/></xsl:variable>
  8. <xsl:variable name="Generator"><xsl:value-of select="@Generator"/></xsl:variable>
  9. <xsl:variable name="CompilerName"><xsl:value-of select="@CompilerName"/></xsl:variable>
  10. <xsl:variable name="OSName"><xsl:value-of select="@OSName"/></xsl:variable>
  11. <xsl:variable name="Hostname"><xsl:value-of select="@Hostname"/></xsl:variable>
  12. <xsl:variable name="OSRelease"><xsl:value-of select="@OSRelease"/></xsl:variable>
  13. <xsl:variable name="OSVersion"><xsl:value-of select="@OSVersion"/></xsl:variable>
  14. <xsl:variable name="OSPlatform"><xsl:value-of select="@OSPlatform"/></xsl:variable>
  15. <xsl:variable name="Is64Bits"><xsl:value-of select="@Is64Bits"/></xsl:variable>
  16. <xsl:variable name="VendorString"><xsl:value-of select="@VendorString"/></xsl:variable>
  17. <xsl:variable name="VendorID"><xsl:value-of select="@VendorID"/></xsl:variable>
  18. <xsl:variable name="FamilyID"><xsl:value-of select="@FamilyID"/></xsl:variable>
  19. <xsl:variable name="ModelID"><xsl:value-of select="@ModelID"/></xsl:variable>
  20. <xsl:variable name="ProcessorCacheSize"><xsl:value-of select="@ProcessorCacheSize"/></xsl:variable>
  21. <xsl:variable name="NumberOfLogicalCPU"><xsl:value-of select="@NumberOfLogicalCPU"/></xsl:variable>
  22. <xsl:variable name="NumberOfPhysicalCPU"><xsl:value-of select="@NumberOfPhysicalCPU"/></xsl:variable>
  23. <xsl:variable name="TotalVirtualMemory"><xsl:value-of select="@TotalVirtualMemory"/></xsl:variable>
  24. <xsl:variable name="TotalPhysicalMemory"><xsl:value-of select="@TotalPhysicalMemory"/></xsl:variable>
  25. <xsl:variable name="LogicalProcessorsPerPhysical"><xsl:value-of select="@LogicalProcessorsPerPhysical"/></xsl:variable>
  26. <xsl:variable name="ProcessorClockFrequency"><xsl:value-of select="@ProcessorClockFrequency"/></xsl:variable>
  27. <properties>
  28. <property name="BuildName" value="{$BuildName}" />
  29. <property name="BuildStamp" value="{$BuildStamp}" />
  30. <property name="Name" value="{$Name}" />
  31. <property name="Generator" value="{$Generator}" />
  32. <property name="CompilerName" value="{$CompilerName}" />
  33. <property name="OSName" value="{$OSName}" />
  34. <property name="Hostname" value="{$Hostname}" />
  35. <property name="OSRelease" value="{$OSRelease}" />
  36. <property name="OSVersion" value="{$OSVersion}" />
  37. <property name="OSPlatform" value="{$OSPlatform}" />
  38. <property name="Is64Bits" value="{$Is64Bits}" />
  39. <property name="VendorString" value="{$VendorString}" />
  40. <property name="VendorID" value="{$VendorID}" />
  41. <property name="FamilyID" value="{$FamilyID}" />
  42. <property name="ModelID" value="{$ModelID}" />
  43. <property name="ProcessorCacheSize" value="{$ProcessorCacheSize}" />
  44. <property name="NumberOfLogicalCPU" value="{$NumberOfLogicalCPU}" />
  45. <property name="NumberOfPhysicalCPU" value="{$NumberOfPhysicalCPU}" />
  46. <property name="TotalVirtualMemory" value="{$TotalVirtualMemory}" />
  47. <property name="TotalPhysicalMemory" value="{$TotalPhysicalMemory}" />
  48. <property name="LogicalProcessorsPerPhysical" value="{$LogicalProcessorsPerPhysical}" />
  49. <property name="ProcessorClockFrequency" value="{$ProcessorClockFrequency}" />
  50. </properties>
  51. <xsl:apply-templates select="Testing/Test"/>
  52. <system-out>
  53. BuildName: <xsl:value-of select="$BuildName" />
  54. BuildStamp: <xsl:value-of select="$BuildStamp" />
  55. Name: <xsl:value-of select="$Name" />
  56. Generator: <xsl:value-of select="$Generator" />
  57. CompilerName: <xsl:value-of select="$CompilerName" />
  58. OSName: <xsl:value-of select="$OSName" />
  59. Hostname: <xsl:value-of select="$Hostname" />
  60. OSRelease: <xsl:value-of select="$OSRelease" />
  61. OSVersion: <xsl:value-of select="$OSVersion" />
  62. OSPlatform: <xsl:value-of select="$OSPlatform" />
  63. Is64Bits: <xsl:value-of select="$Is64Bits" />
  64. VendorString: <xsl:value-of select="$VendorString" />
  65. VendorID: <xsl:value-of select="$VendorID" />
  66. FamilyID: <xsl:value-of select="$FamilyID" />
  67. ModelID: <xsl:value-of select="$ModelID" />
  68. ProcessorCacheSize: <xsl:value-of select="$ProcessorCacheSize" />
  69. NumberOfLogicalCPU: <xsl:value-of select="$NumberOfLogicalCPU" />
  70. NumberOfPhysicalCPU: <xsl:value-of select="$NumberOfPhysicalCPU" />
  71. TotalVirtualMemory: <xsl:value-of select="$TotalVirtualMemory" />
  72. TotalPhysicalMemory: <xsl:value-of select="$TotalPhysicalMemory" />
  73. LogicalProcessorsPerPhysical: <xsl:value-of select="$LogicalProcessorsPerPhysical" />
  74. ProcessorClockFrequency: <xsl:value-of select="$ProcessorClockFrequency" />
  75. </system-out>
  76. </testsuite>
  77. </xsl:template>
  78. <xsl:template match="Testing/Test">
  79. <xsl:variable name="testcasename"><xsl:value-of select= "Name"/></xsl:variable>
  80. <xsl:variable name="exectime">
  81. <xsl:for-each select="Results/NamedMeasurement">
  82. <xsl:if test="@name = 'Execution Time'">
  83. <xsl:value-of select="."/>
  84. </xsl:if>
  85. </xsl:for-each>
  86. </xsl:variable>
  87. <testcase name="{$testcasename}" classname="TestSuite" time="{$exectime}">
  88. <xsl:if test="@Status = 'passed'">
  89. </xsl:if>
  90. <xsl:if test="@Status = 'failed'">
  91. <xsl:variable name="failtype">
  92. <xsl:for-each select="Results/NamedMeasurement">
  93. <xsl:if test="@name = 'Exit Code'">
  94. <xsl:value-of select="."/>
  95. </xsl:if>
  96. </xsl:for-each>
  97. </xsl:variable>
  98. <xsl:variable name="failcode">
  99. <xsl:for-each select="Results/NamedMeasurement">
  100. <xsl:if test="@name = 'Exit Value'">
  101. <xsl:value-of select="."/>
  102. </xsl:if>
  103. </xsl:for-each>
  104. </xsl:variable>
  105. <error message="{$failtype} ({$failcode})"><xsl:value-of select="Results/Measurement/Value/text()" /></error>
  106. </xsl:if>
  107. <xsl:if test="@Status = 'notrun'">
  108. <skipped><xsl:value-of select="Results/Measurement/Value/text()" /></skipped>
  109. </xsl:if>
  110. </testcase>
  111. </xsl:template>
  112. </xsl:stylesheet>