Syntax Test Report

Version 2.2 by Vincent Massol on 2012/05/12 12:26

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

Code

{{groovy}}
import java.net.URLDecoder

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
  State outResult
}

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("\\\\/", "/")
  def matcher = testAsString =~ "(.*)\\((.*)\\) \\[(.*)\\](.*)"
  def syntaxId = matcher[0][3]
  def type = matcher[0][2]
  def name = matcher[0][1]
  def stateAsString = matcher[0][4]
  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
  } else {
    result.outResult = state
  }
}

// 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' title='**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 applicable"
println "{{/box}}"

println "|=Syntax|=Test|=Result IN|=Result OUT"
testsBySyntax.each() { syntax, testByName ->
  testByName.each() { name, result ->
    println "|${syntax}|${name}|(% style='background-color: ${result.inResult.color()}' %)|(% style='background-color: ${result.outResult.color()}' %)"
  }
}
{{/groovy}}

Result

syntaxreport.png

Get Connected