simpletest_to_junit.xsl 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. version="1.0">
  4. <!-- convert xml output generated by simpletest xml into junit xml format -->
  5. <xsl:output method="xml"/>
  6. <xsl:template match="/">
  7. <xsl:apply-templates select="run/group"/>
  8. </xsl:template>
  9. <xsl:template match="run/group">
  10. <testsuite>
  11. <xsl:attribute name="errors"><xsl:value-of select="count(.//exception)"/></xsl:attribute>
  12. <xsl:attribute name="failures"><xsl:value-of select="count(.//fail)"/></xsl:attribute>
  13. <xsl:attribute name="tests"><xsl:value-of select="count(.//test)"/></xsl:attribute>
  14. <xsl:attribute name="name"><xsl:value-of select="name"/></xsl:attribute>
  15. <xsl:attribute name="time"><xsl:value-of select="sum(//time)"/></xsl:attribute>
  16. <xsl:apply-templates select=".//case/test"/>
  17. <xsl:copy-of select="//system-err"/>
  18. </testsuite>
  19. </xsl:template>
  20. <xsl:template match="case/test">
  21. <testcase>
  22. <xsl:attribute name="classname"><xsl:value-of select="../name"/></xsl:attribute>
  23. <xsl:attribute name="name"><xsl:value-of select="name"/></xsl:attribute>
  24. <xsl:attribute name="time"><xsl:value-of select="time"/></xsl:attribute>
  25. <xsl:apply-templates select="fail"/>
  26. <xsl:apply-templates select="exception"/>
  27. </testcase>
  28. </xsl:template>
  29. <xsl:template match="fail">
  30. <failure><xsl:attribute name="message"><xsl:value-of select="."/></xsl:attribute>
  31. <!-- content is for stacktrace; not available / broken out by simpletest -->
  32. </failure>
  33. </xsl:template>
  34. <xsl:template match="exception">
  35. <!-- assuming same format as fail -->
  36. <error><xsl:attribute name="message"><xsl:value-of select="."/></xsl:attribute>
  37. <!-- content is for stacktrace; not available / broken out by simpletest -->
  38. </error>
  39. </xsl:template>
  40. </xsl:stylesheet>