Syntax Test Report

Version 6.1 by Vincent Massol on 2012/05/13 18:09

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

{{groovy}}
import java.net.URLDecoder
import org.apache.commons.configuration.PropertiesConfiguration

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

enum State {
PASSED("#039915"), FAILING("#F50A21"), NOT_APPLICABLE("#C2C0C0"), MISSING("#F59B0A")
State(String color) { this.color = color }
private final String color
public String color() { return color }
}

class Result {
  State inResult
  String inSyntaxExtension
  String inCtsExtension
  State outResult
  String outSyntaxExtension
  String outCtsExtension
}

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

def tests = [] as Set
def testsBySyntax = [:]

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", ",")
  def matcher = testAsString =~ "(.*) \\[(.*), (.*):(.*), CTS:(.*)\\](.*)"
  def syntaxId = matcher[0][2]
  def type = matcher[0][3]
  def name = matcher[0][1]
  def syntaxExtension = matcher[0][4]
  def ctsExtension = matcher[0][5]
  def stateAsString = matcher[0][6]
  def state
  if (it.skipped == "true") {
    if (stateAsString == " - Not working") {
      state = State.FAILING
    } else {
      state = State.MISSING
    }
  } else {
    state = State.PASSED
  }
      
  tests.add(name)

  def testData = testsBySyntax.get(syntaxId)
  if (!testData) {
    testData = [:]
    testsBySyntax.put(syntaxId, testData) 
  }

  def result = testData.get(name)
  if (!result) {
    result = new Result()
    testData.put(name, result)
  }

  if (type == "IN") {
    result.inResult = state
    result.inSyntaxExtension = syntaxExtension
    result.inCtsExtension = ctsExtension
  } else {
    result.outResult = state
    result.outSyntaxExtension = syntaxExtension
    result.outCtsExtension = ctsExtension
  }
}

// Normalize Map by adding not applicable tests for syntaxes
testsBySyntax.each() { syntax, testByName ->
  tests.each() { name ->
    def result = testByName.get(name)
    if (!result) {
      result = new Result()
      testByName.put(name, result)
    }
    if (!result.inResult) {
      result.inResult = State.NOT_APPLICABLE
    }
    if (!result.outResult) {
      result.outResult = State.NOT_APPLICABLE
    }
  }
}

testsBySyntax = testsBySyntax.sort()

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

println "|=Syntax|=Test|=Result IN|=Result OUT"
testsBySyntax.each() { syntax, testByName ->

  // 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}"

  testByName.each() { name, result ->

    def inCellResult
    if (result.inResult != State.NOT_APPLICABLE) {
      def syntaxInCell = "${syntaxLocation}/${name}${result.inSyntaxExtension}"
      def ctsInCell = "https://raw.github.com/xwiki/xwiki-rendering/master/xwiki-rendering-test/src/main/resources/cts/${name}${result.inCtsExtension}"
      inCellResult = "(% style='background-color: ${result.inResult.color()}' %)[[IN>>${syntaxInCell}]] / [[CTS>>${ctsInCell}]]"
    } else {
      inCellResult = "(% style='background-color: ${result.inResult.color()}' %)"
    }

    def outCellResult
    if (result.outResult != State.NOT_APPLICABLE) {
      def syntaxOutCell = "${syntaxLocation}/${name}${result.outSyntaxExtension}"
      def ctsOutCell = "https://raw.github.com/xwiki/xwiki-rendering/master/xwiki-rendering-test/src/main/resources/cts/${name}${result.outCtsExtension}"
      outCellResult = "(% style='background-color: ${result.outResult.color()}' %)[[CTS>>${ctsOutCell}]] / [[OUT>>${syntaxOutCell}]]"
    } else {
      outCellResult = "(% style='background-color: ${result.outResult.color()}' %)"
    }

    println "|${syntax}|${name}|${inCellResult}|${outCellResult}"
  }
}
{{/groovy}}

Result

syntaxreport.png

Get Connected