Syntax Test Report

Version 13.1 by Vincent Massol on 2012/05/17 19:33

cogDisplays the results of the Compatibility Test Suite for all Syntaxes
TypeSnippet
Category
Developed by

Vincent Massol

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

Table of contents

Description

The Rendering module has a Compatibility Test Suite (CTS) which defines Rendering tests and those tests are executed for each supported Syntax.

This snippet provides an overview of the test results. You can also see it live on the Rendering Wiki.

Code

{{ctsdata}}
{{groovy}}
def url = "http://ci.xwiki.org/job/xwiki-rendering/lastSuccessfulBuild/testReport/api/xml?xpath=//suite/case/className%5Btext()%20=%20'org.xwiki.rendering.test.cts.RenderingTest'%5D/..&wrapper=root".toURL().text
def root = new XmlSlurper().parseText(url)
root."case".each() { it ->
  def testAsString = it.name.text().replaceAll("\\\\/", "/").replaceAll("\\\\u002C", ",")
  if (it.skipped == "false") {
    testAsString = "${testAsString} - Passed" 
  }
  if (testAsString.endsWith("Test needed")) {
    testAsString = testAsString.replace("Test needed", "Missing")
  } else if (testAsString.endsWith("Not working")) {
    testAsString = testAsString.replace("Not working", "Failing")
  }
  println testAsString
}
{{/groovy}}
{{/ctsdata}}

{{groovy}}
import org.apache.commons.configuration.PropertiesConfiguration
import org.xwiki.rendering.internal.macro.ctsreport.State

def colors = [PASSED:"039915", FAILING:"F50A21", MISSING:"F59B0A", NOT_APPLICABLE:"C2C0C0"]

def descriptions
try {
  def config = new PropertiesConfiguration("https://raw.github.com/xwiki/xwiki-rendering/master/xwiki-rendering-test/src/main/resources/cts/config.properties".toURL())
   descriptions = config.getProperties("testDescriptions", new Properties())
} catch (e) {
  descriptions = new Properties()
}

println "{{box cssClass='floatinginfobox'}}"
println "**Legend**"
println "|(% style='background-color: #${colors.get("PASSED")}' %)|Passed test"
println "|(% style='background-color: #${colors.get("FAILING")}' %)|Failing test (needs to be fixed)"
println "|(% style='background-color: #${colors.get("MISSING")}' %)|Missing test (needs to be written)"
println "|(% style='background-color: #${colors.get("NOT_APPLICABLE")}' %)|Not supported"
if (!descriptions.isEmpty()) {
  println ""
  println "**Test Descriptions**"
  ctsTestNames.each() { name ->
    println "|${name}|${descriptions.get(name)}"
  }
}
println "{{/box}}"

println ""
println "Test Reports for the following syntaxes:"
println ""
println "{{toc/}}"
println ""

def syntaxModules = ["xwiki/2.0":"xwiki20", "xwiki/2.1":"xwiki21", "xwiki/1.0":"xwiki10"]

ctsTests.each() { syntax, inOutTests ->
  def nbTests = [PASSED:0, FAILING:0, MISSING:0, NOT_APPLICABLE:0]

  // Find the syntax module name
  def syntaxResourceName = syntax.replace("/", "").replace(".", "")
  def syntaxModuleName = syntaxModules.get(syntax)
  if (!syntaxModuleName) {
    syntaxModuleName = syntax.find(/\w+/)
  }
  def syntaxLocation = "https://raw.github.com/xwiki/xwiki-rendering/master/xwiki-rendering-syntaxes/xwiki-rendering-syntax-${syntaxModuleName}/src/test/resources/${syntaxResourceName}"

  println "= Syntax: ${syntax} ="

  def inTests = inOutTests.getLeft()
  def buffer = []
  if (inTests.isEmpty()) {
    buffer.add("There is no Parser for this syntax.")
  } else {
    buffer.add("Parser Tests:")
    buffer.add("|=Input|=Expected Output|=Result")
    inTests.each() { test ->

      int nb = nbTests.get(test.state.toString())
      nbTests.put(test.state.toString(), ++nb)

      def syntaxExtension = test.syntaxExtension ?: ""
      def ctsExtension = test.ctsExtension ?: ""

      // Compute link to sources
      def ctsCell = "[[${test.prefix}${syntaxExtension}>>https://raw.github.com/xwiki/xwiki-rendering/master/xwiki-rendering-test/src/main/resources/cts/${test.prefix}${ctsExtension}]]"
      def syntaxCell = "[[${test.prefix}${syntaxExtension}>>${syntaxLocation}/${test.prefix}${test.syntaxExtension}]]"

      buffer.add("|${syntaxCell}|${ctsCell}|(% style='background-color: #${colors.get(test.state.name())}' %)")
    }
  }  
  buffer += ""

  def outTests = inOutTests.getRight()
  if (outTests.isEmpty()) {
    buffer.add("There is no Renderer for this syntax.")
  } else {
    buffer.add("Renderer Tests:")
    buffer.add("|=Input|=Expected Output|=Result")
    outTests.each() { test ->

      int nb = nbTests.get(test.state.toString())
      nbTests.put(test.state.toString(), ++nb)

      def syntaxExtension = test.syntaxExtension ?: ""
      def ctsExtension = test.ctsExtension ?: ""

      // Compute link to sources
      def ctsCell = "[[${test.prefix}${syntaxExtension}>>https://raw.github.com/xwiki/xwiki-rendering/master/xwiki-rendering-test/src/main/resources/cts/${test.prefix}${ctsExtension}]]"
      def syntaxCell = "[[${test.prefix}${syntaxExtension}>>${syntaxLocation}/${test.prefix}${test.syntaxExtension}]]"

      buffer.add("|${ctsCell}|${syntaxCell}|(% style='background-color: #${colors.get(test.state.name())}' %)")
    }
  }

  def colorsAsString = colors.values().join(',')
  println "{{chart type='pie' source='inline' params='range:B2-B${nbTests.size() + 1};series:columns;colors:${colorsAsString}' title='Summary for ${syntax}'}}"
  println "|  |Value"
  nbTests.each() { state, nb ->
    println "|${state}|${nb}"
  }
  println "{{/chart}}"

  buffer.each() { println it }
}
{{/groovy}}

Result

syntaxreport.png

Get Connected