You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2007/02/06 06:54:24 UTC
svn commit: r504001 - in
/geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report:
./ resources/
Author: jdillon
Date: Mon Feb 5 21:54:24 2007
New Revision: 504001
URL: http://svn.apache.org/viewvc?view=rev&rev=504001
Log:
Hacked up some stats collection to get class, package and iteration summaries with real details
Its kinda ugly, but works... :-\
Added:
geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/Stats.groovy (with props)
geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/StatsCollector.groovy (with props)
geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/iteration.tmpl (with props)
Modified:
geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/ReportGenerator.groovy
geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/class-summary.tmpl
geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/package-summary.tmpl
Modified: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/ReportGenerator.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/ReportGenerator.groovy?view=diff&rev=504001&r1=504000&r2=504001
==============================================================================
--- geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/ReportGenerator.groovy (original)
+++ geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/ReportGenerator.groovy Mon Feb 5 21:54:24 2007
@@ -37,6 +37,8 @@
{
AntBuilder ant = new gbuild.system.util.AntBuilder()
+ TemplateEngine engine = new TemplateEngine('gbuild/config/projects/Geronimo_CTS/report/resources')
+
List archives
File targetDir
@@ -82,9 +84,6 @@
ant.delete(dir: workDir)
ant.delete(dir: targetDir)
- // Setup the template engine
- def engine = new TemplateEngine('gbuild/config/projects/Geronimo_CTS/report/resources')
-
def loadTestSuite = { dir ->
log.info "Loading testsuite from: $dir"
@@ -94,16 +93,16 @@
}
}
- def testCases = []
- scanner.each { file ->
- testCases << TestCase.fromFile(file)
- }
-
log.info 'Loading testsuite'
def watch = new StopWatch()
watch.start()
+ def testCases = []
+ scanner.each { file ->
+ testCases << TestCase.fromFile(file)
+ }
+
def testSuite = new TestSuite(testCases)
watch.stop()
@@ -126,6 +125,9 @@
// Load the testuite
def testSuite = loadTestSuite(workDir)
+ // Save stats for each set of results
+ def stats = new StatsCollector()
+
def renderTestCase = { testCase ->
log.info "Processing testcase: $testCase.name"
@@ -138,36 +140,36 @@
template.render(file)
}
- def testsInClasses = [:]
- def classesInPackages = [:]
-
+ // Render testcase details
testSuite.testCases.each { name, testCase ->
+ stats << testCase
+
renderTestCase(testCase)
+ }
+
+ // Render package summaries
+ stats.classesInPackages.each { packageName, classNames ->
+ log.info "Processing package summary: $packageName"
- def list
+ def template = engine.getTemplate('package-summary.tmpl')
+ template.params.packageName = packageName
+ template.params.classNames = classNames
+ template.params.stats = stats
- list = testsInClasses[testCase.className]
- if (!list) {
- list = new HashSet()
- testsInClasses[testCase.className] = list
- }
- list << testCase.name
+ def file = new File(targetDir, makeSafeFilename(packageName) + '/index.html')
+ ant.mkdir(dir: file.parentFile)
- list = classesInPackages[testCase.packageName]
- if (!list) {
- list = new HashSet()
- classesInPackages[testCase.packageName] = list
- }
- list << testCase.className
+ template.render(file)
}
// Render class summaries
- testsInClasses.each { className, testNames ->
+ stats.testsInClasses.each { className, testNames ->
log.info "Processing class summary: $className"
def template = engine.getTemplate('class-summary.tmpl')
template.params.className = className
template.params.testNames = testNames
+ template.params.stats = stats
def file = new File(targetDir, makeSafeFilename(className) + '/index.html')
ant.mkdir(dir: file.parentFile)
@@ -175,23 +177,36 @@
template.render(file)
}
- // Render package summaries
- classesInPackages.each { packageName, classNames ->
- log.info "Processing package summary: $packageName"
-
- def template = engine.getTemplate('package-summary.tmpl')
- template.params.packageName = packageName
- template.params.classNames = classNames
-
- def file = new File(targetDir, makeSafeFilename(packageName) + '/index.html')
- ant.mkdir(dir: file.parentFile)
-
- template.render(file)
- }
+ // Render iteration details
+ log.info "Rendering iteration summary: $props.iteration"
+ def template = engine.getTemplate('iteration.tmpl')
+ template.params.stats = stats
+ template.params.props = props
+ template.params.iteration = props.iteration
+
+ def file = new File(targetDir, "iteration-${props.iteration}.html")
+ ant.mkdir(dir: file.parentFile)
+ template.render(file)
+
+ //
+ // TODO: Save stats for global summary
+ //
// Clean up
log.info "Cleaning up"
ant.delete(dir: workDir)
}
+
+ //
+ // TODO: Render summary overview
+ //
+
+ //
+ // TODO: Render interation summary
+ //
+
+ //
+ // TODO: Install resources and generate frames pages
+ //
}
}
Added: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/Stats.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/Stats.groovy?view=auto&rev=504001
==============================================================================
--- geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/Stats.groovy (added)
+++ geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/Stats.groovy Mon Feb 5 21:54:24 2007
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+//
+// $Id$
+//
+
+package gbuild.config.projects.Geronimo_CTS.report
+
+import org.apache.commons.lang.time.DurationFormatUtils
+
+/**
+ * ???
+ */
+class Stats
+{
+ long passCount = 0
+
+ long failureCount = 0
+
+ long errorCount = 0
+
+ long time = 0
+
+ def leftShift(TestCase testCase) {
+ if (testCase.status.passed) {
+ passCount++
+ }
+ if (testCase.status.failed) {
+ failureCount++
+ }
+ if (testCase.status.error) {
+ errorCount++
+ }
+ time += testCase.time
+ }
+
+ long getCount() {
+ return passCount + failureCount + errorCount
+ }
+
+ String getDuration() {
+ return DurationFormatUtils.formatDurationHMS(time)
+ }
+
+ boolean getPassed() {
+ return failureCount + errorCount == 0
+ }
+
+ double getSuccessRate() {
+ return passCount * 100 / count
+ }
+}
+
Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/Stats.groovy
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/Stats.groovy
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/Stats.groovy
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/StatsCollector.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/StatsCollector.groovy?view=auto&rev=504001
==============================================================================
--- geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/StatsCollector.groovy (added)
+++ geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/StatsCollector.groovy Mon Feb 5 21:54:24 2007
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+//
+// $Id$
+//
+
+package gbuild.config.projects.Geronimo_CTS.report
+
+import gbuild.system.LogSupport
+
+import org.apache.commons.lang.time.DurationFormatUtils
+
+/**
+ * ???
+ */
+class StatsCollector extends LogSupport
+{
+ Map byPackage = [:]
+
+ Map byClass = [:]
+
+ Map testsInClasses = [:]
+
+ Map classesInPackages = [:]
+
+ Map testCaseByName = [:]
+
+ Set packageNames = new HashSet()
+
+ def getStats(Map map, String key) {
+ def stats = map[key]
+ if (!stats) {
+ stats = new Stats()
+ map[key] = stats
+ }
+
+ return stats
+ }
+
+ def getSet(Map map, String key) {
+ def set = map[key]
+ if (!set) {
+ set = new HashSet()
+ map[key] = set
+ }
+
+ return set
+ }
+
+ def leftShift(TestCase testCase) {
+ assert testCase
+
+ getStats(byPackage, testCase.packageName) << testCase
+
+ getSet(classesInPackages, testCase.packageName) << testCase.className
+
+ getStats(byClass, testCase.className) << testCase
+
+ getSet(testsInClasses, testCase.className) << testCase.name
+
+ testCaseByName[testCase.name] = testCase
+
+ packageNames << testCase.packageName
+ }
+
+ //
+ // HACK: Global stats
+ //
+
+ private long sum(name) {
+ long sum = 0
+ byPackage.each{ sum += it.value[name] }
+ return sum
+ }
+
+ long getPassCount() {
+ return sum('passCount')
+ }
+
+ long getFailureCount() {
+ return sum('failureCount')
+ }
+
+ long getErrorCount() {
+ return sum('errorCount')
+ }
+
+ long getTime() {
+ return sum('time')
+ }
+
+ long getCount() {
+ return passCount + failureCount + errorCount
+ }
+
+ String getDuration() {
+ return DurationFormatUtils.formatDurationHMS(time)
+ }
+
+ boolean getPassed() {
+ return failureCount + errorCount == 0
+ }
+
+ double getSuccessRate() {
+ return passCount * 100 / count
+ }
+}
+
Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/StatsCollector.groovy
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/StatsCollector.groovy
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/StatsCollector.groovy
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/class-summary.tmpl
URL: http://svn.apache.org/viewvc/geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/class-summary.tmpl?view=diff&rev=504001&r1=504000&r2=504001
==============================================================================
--- geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/class-summary.tmpl (original)
+++ geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/class-summary.tmpl Mon Feb 5 21:54:24 2007
@@ -30,13 +30,60 @@
<div>
<h1>$className</h1>
+ <h2>Summary</h2>
+
+ <% def classSummary = stats.byClass[className] %>
+
<table>
- <% for (testName in testNames) { %>
<tr>
- <% def basename = testName.substring(testName.lastIndexOf('#') + 1, testName.size()) %>
- <td><a href="${basename}.html">$testName</a></td>
+ <td>Tests</td>
+ <td>$classSummary.count</td>
</tr>
- <% } %>
+ <tr>
+ <td>Passed</td>
+ <td>$classSummary.passCount</td>
+ </tr>
+ <tr>
+ <td>Failed</td>
+ <td>$classSummary.failureCount</td>
+ </tr>
+ <tr>
+ <td>Errors</td>
+ <td>$classSummary.errorCount</td>
+ </tr>
+ <tr>
+ <td>Success Rate</td>
+ <td>$classSummary.successRate</td>
+ </tr>
+ <tr>
+ <td>Duration</td>
+ <td>$classSummary.duration</td>
+ </tr>
+ </table>
+
+ <h2>Tests</h2>
+
+ <table>
+ <thead>
+ <tr>
+ <th>Test</th>
+ <th>Status</th>
+ <th>Duration</td>
+ </tr>
+ </thead>
+ <tbody>
+ <% for (testName in testNames) { %>
+ <%
+ def basename = testName.substring(testName.lastIndexOf('#') + 1, testName.size())
+ def testCase = stats.testCaseByName[testName]
+ %>
+ <tr>
+ <td><a href="${basename}.html">$testCase.testName</a></td>
+ <td>$testCase.status.text</td>
+ <td>$testCase.duration</td>
+ </tr>
+ <% } %>
+ </tbody>
</table>
</div>
</body>
Added: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/iteration.tmpl
URL: http://svn.apache.org/viewvc/geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/iteration.tmpl?view=auto&rev=504001
==============================================================================
--- geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/iteration.tmpl (added)
+++ geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/iteration.tmpl Mon Feb 5 21:54:24 2007
@@ -0,0 +1,112 @@
+<%
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+//
+// $Id$
+//
+
+def sorter = { String a, String b ->
+ return a.toLowerCase() <=> b.toLowerCase()
+}
+
+%>
+<html>
+<head>
+ <title>Iteration $iteration</title>
+</head>
+<body>
+ <div>
+ <h1>Iteration $iteration</h1>
+
+ <h2>Summary</h2>
+
+ <table>
+ <tr>
+ <td>Tests</td>
+ <td>$stats.count</td>
+ </tr>
+ <tr>
+ <td>Passed</td>
+ <td>$stats.passCount</td>
+ </tr>
+ <tr>
+ <td>Failed</td>
+ <td>$stats.failureCount</td>
+ </tr>
+ <tr>
+ <td>Errors</td>
+ <td>$stats.errorCount</td>
+ </tr>
+ <tr>
+ <td>Success Rate</td>
+ <td>$stats.successRate</td>
+ </tr>
+ <tr>
+ <td>Duration</td>
+ <td>$stats.duration</td>
+ </tr>
+ </table>
+
+ <h2>Packages</h2>
+
+ <table>
+ <thead>
+ <tr>
+ <th>Package</th>
+ <th>Tests</th>
+ <th>Failures</th>
+ <th>Errors</th>
+ <th>Success Rate</td>
+ <th>Duration</td>
+ </tr>
+ </thead>
+ <tbody>
+ <% stats.packageNames.sort(sorter).each { packageName -> %>
+ <%
+ def packageSummary = stats.byPackage[packageName]
+ def href = packageName.replace('.', '/') + '/index.html'
+ %>
+ <tr>
+ <td><a href="$href">$packageName</a></td>
+ <td>$packageSummary.count</td>
+ <td>$packageSummary.failureCount</td>
+ <td>$packageSummary.errorCount</td>
+ <td>$packageSummary.successRate</td>
+ <td>$packageSummary.duration</td>
+ </tr>
+ <% } %>
+ </tbody>
+ </table>
+
+ <h2>Details</h2>
+
+ <h3>Runtests Properties</h3>
+
+ <table>
+ <% props.keySet().sort(sorter).each { name -> %>
+ <tr>
+ <td>$name</td>
+ <td>${props[name]}</td>
+ </tr>
+ <% } %>
+ </table>
+ </div>
+</body>
+</html>
Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/iteration.tmpl
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/iteration.tmpl
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/iteration.tmpl
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/package-summary.tmpl
URL: http://svn.apache.org/viewvc/geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/package-summary.tmpl?view=diff&rev=504001&r1=504000&r2=504001
==============================================================================
--- geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/package-summary.tmpl (original)
+++ geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/package-summary.tmpl Mon Feb 5 21:54:24 2007
@@ -30,13 +30,65 @@
<div>
<h1>$packageName</h1>
+ <h2>Summary</h2>
+
+ <% def packageSummary = stats.byPackage[packageName] %>
<table>
- <% for (className in classNames) { %>
<tr>
- <% def basename = className.substring(className.lastIndexOf('.') + 1, className.size()) %>
- <td><a href="${basename}/index.html">$className</a></td>
+ <td>Tests</td>
+ <td>$packageSummary.count</td>
</tr>
- <% } %>
+ <tr>
+ <td>Passed</td>
+ <td>$packageSummary.passCount</td>
+ </tr>
+ <tr>
+ <td>Failed</td>
+ <td>$packageSummary.failureCount</td>
+ </tr>
+ <tr>
+ <td>Errors</td>
+ <td>$packageSummary.errorCount</td>
+ </tr>
+ <tr>
+ <td>Success Rate</td>
+ <td>$packageSummary.successRate</td>
+ </tr>
+ <tr>
+ <td>Duration</td>
+ <td>$packageSummary.duration</td>
+ </tr>
+ </table>
+
+ <h2>Classes</h2>
+
+ <table>
+ <thead>
+ <tr>
+ <th>Class</th>
+ <th>Tests</th>
+ <th>Failures</th>
+ <th>Errors</th>
+ <th>Success Rate</td>
+ <th>Duration</td>
+ </tr>
+ </thead>
+ <tbody>
+ <% for (className in classNames) { %>
+ <%
+ def classSummary = stats.byClass[className]
+ def basename = className.substring(className.lastIndexOf('.') + 1, className.size())
+ %>
+ <tr>
+ <td><a href="${basename}/index.html">$className</a></td>
+ <td>$classSummary.count</td>
+ <td>$classSummary.failureCount</td>
+ <td>$classSummary.errorCount</td>
+ <td>$classSummary.successRate</td>
+ <td>$classSummary.duration</td>
+ </tr>
+ <% } %>
+ </tbody>
</table>
</div>
</body>