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 @@
| $testName | +Tests | +$classSummary.count |
| Passed | +$classSummary.passCount | +|
| Failed | +$classSummary.failureCount | +|
| Errors | +$classSummary.errorCount | +|
| Success Rate | +$classSummary.successRate | +|
| Duration | +$classSummary.duration | +
| Test | +Status | +Duration + |
|---|---|---|
| $testCase.testName | +$testCase.status.text | +$testCase.duration | +
| Tests | +$stats.count | +
| Passed | +$stats.passCount | +
| Failed | +$stats.failureCount | +
| Errors | +$stats.errorCount | +
| Success Rate | +$stats.successRate | +
| Duration | +$stats.duration | +
| Package | +Tests | +Failures | +Errors | +Success Rate + | Duration + |
|---|---|---|---|---|---|
| $packageName | +$packageSummary.count | +$packageSummary.failureCount | +$packageSummary.errorCount | +$packageSummary.successRate | +$packageSummary.duration | +
| $name | +${props[name]} | +
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() +} + +%> + +
+
+ +
+