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/01 16:45:54 UTC
svn commit: r502246 - in
/geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report:
ParseException.groovy Section.groovy TestResult.groovy
Author: jdillon
Date: Thu Feb 1 07:45:53 2007
New Revision: 502246
URL: http://svn.apache.org/viewvc?view=rev&rev=502246
Log:
Re-write parsing using closures; don't need Sections or ParseException anymore
Cleaned up logging; still a bunch of stuff an INFO while I finish testing, then will turn to debug
Removed:
geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/ParseException.groovy
geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/Section.groovy
Modified:
geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/TestResult.groovy
Modified: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/TestResult.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/TestResult.groovy?view=diff&rev=502246&r1=502245&r2=502246
==============================================================================
--- geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/TestResult.groovy (original)
+++ geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/TestResult.groovy Thu Feb 1 07:45:53 2007
@@ -30,6 +30,8 @@
*/
class TestResult extends LogSupport
{
+ static final STREAM_HEADER_PATTERN = ~/----------([^:]*):\(([0-9]*)\/([0-9]*)\)----------/
+
String checksum
Map desc
@@ -46,89 +48,151 @@
load(file)
}
- def scanFor(input, text) {
- log.info "Scanning for: $text"
-
- def line
-
- while ((line = input.readLine()) != null) {
- if (line.startsWith(text)) {
- return line
- }
- }
-
- throw new ParseException("Missing line with: $text")
- }
-
def load(file) {
assert file
file = new File("$file")
assert file.exists()
+ boolean debug = log.debugEnabled
+
log.info "Loading test result from: $file"
def input = file.newReader()
- try {
- // Read the header
- assert input.readLine() == '#Test Results (version 2)'
+ def readLine = {
+ def line = input.readLine()
- checksum = scanFor(input, '#checksum:').tokenize(':')[1]
- log.info "Checksum: $checksum"
+ if (debug) {
+ log.debug("Read> $line")
+ }
- // Read the test description
- scanFor(input, '#-----testdescription-----')
- desc = loadProperties(input)
-
- // Read the environment
- scanFor(input, '#-----environment-----')
- env = loadProperties(input)
-
- // Read the test result properties
- scanFor(input, '#-----testresult-----')
- props = loadProperties(input)
-
- // Load test sections
- sections = new LinkedHashMap()
- for (name in props['sections'].tokenize()) {
- log.info "Section: $name"
- sections[name] = new Section(input)
+ return line
+ }
+
+ def scan = { text ->
+ if (debug) {
+ log.debug "Scanning for: $text"
}
- //
- // NOTE: The next line is probably empty, so we have to check for null
- // Not sure if we can expect input.readLine() == '' always here :-\
- //
+ def line
- status = scanFor(input, 'test result: ').split(' ', 3)[2]
- log.info "Status: $status"
+ while ((line = readLine()) != null) {
+ if (line.startsWith(text)) {
+ if (debug) {
+ log.debug "Found: $line"
+ }
+
+ return line
+ }
+ }
+
+ throw new Exception("Missing line with: $text")
}
- finally {
- input.close()
+
+ def loadProperties = { title ->
+ scan("#-----${title}-----")
+
+ // keep things in the same order as the jtr file
+ def props = new LinkedHashMap()
+ def line
+
+ // this will break on null or empty line
+ while (line = readLine()) {
+ def parts = line.split('=', 2)
+ assert parts.size() == 2
+
+ props[parts[0]] = parts[1]
+ }
+
+ log.info "Properties '${title}':"
+ props.each {
+ log.info " $it"
+ }
+
+ return props
}
- }
-
- Map loadProperties(BufferedReader input) {
- assert input != null
- // keep things in the same order as the jtr file
- def props = new LinkedHashMap()
- def line
+ def loadStreams = {
+ log.info "Loading streams..."
+
+ def streams = new LinkedHashMap()
+
+ def line
+
+ while (line = readLine()) {
+ def matcher = STREAM_HEADER_PATTERN.matcher(line)
+ if (matcher.matches()) {
+ def stream = new Expando()
+
+ stream.name = matcher[0][1]
+ stream.lines = matcher[0][2]
+ stream.chars = matcher[0][3].toInteger()
+
+ log.info "Loading stream: '$stream.name', $stream.lines lines, $stream.chars characters"
+
+ char[] buff = new char[stream.chars]
+ int c = input.read(buff)
+ assert c == stream.chars
+
+ stream.data = new String(buff)
+ if (debug) {
+ log.debug 'Stream data:\n' + ('-' * 80) + "\n$stream.data" + ('-' * 80)
+ }
+
+ streams[stream.name] = stream
+ }
+ }
+
+ return streams
+ }
- // this will break on null or empty line
- while (line = input.readLine()) {
- def parts = line.split('=', 2)
- assert parts.size() == 2
+ def loadSection = { name ->
+ log.info "Loading section: $name"
- props[parts[0]] = parts[1]
+ def section = new Expando()
+ section.name = name
+ section.streams = loadStreams()
+
+ return section
}
- props.each {
- log.info " $it"
+ def loadSections = {
+ log.info "Loading sections..."
+
+ def sections = new LinkedHashMap()
+
+ props['sections'].tokenize().each { name ->
+ def section = loadSection(name)
+ sections[name] = section
+ }
+
+ return sections
}
- return props
+ try {
+ assert readLine() == '#Test Results (version 2)'
+
+ checksum = scan('#checksum:').tokenize(':')[1]
+
+ desc = loadProperties('testdescription')
+
+ env = loadProperties('environment')
+
+ props = loadProperties('testresult')
+
+ sections = loadSections()
+
+ //
+ // NOTE: The next line is probably empty, so we have to check for null
+ // Not sure if we can expect input.readLine() == '' always here :-\
+ //
+
+ status = scan('test result: ').split(' ', 3)[2]
+ }
+ finally {
+ input.close()
+ }
}
}