geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r502207 - in /geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report: ./ ParseException.groovy Section.groovy TestResult.groovy
Date Thu, 01 Feb 2007 13:23:18 GMT
Author: jdillon
Date: Thu Feb  1 05:23:17 2007
New Revision: 502207

URL: http://svn.apache.org/viewvc?view=rev&rev=502207
Log:
Adding primitive support to parse out .jtr files

Added:
    geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/
    geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/ParseException.groovy
  (with props)
    geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/Section.groovy
  (with props)
    geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/TestResult.groovy
  (with props)

Added: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/ParseException.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/ParseException.groovy?view=auto&rev=502207
==============================================================================
--- geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/ParseException.groovy
(added)
+++ geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/ParseException.groovy
Thu Feb  1 05:23:17 2007
@@ -0,0 +1,36 @@
+/*
+ * 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
+
+class ParseException extends Exception
+{
+    String line
+    
+    def ParseException(String msg, String line=null) {
+        super(msg)
+        
+        this.line = line
+    }
+}
+

Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/ParseException.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/ParseException.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/ParseException.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/Section.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/Section.groovy?view=auto&rev=502207
==============================================================================
--- geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/Section.groovy
(added)
+++ geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/Section.groovy
Thu Feb  1 05:23:17 2007
@@ -0,0 +1,65 @@
+/*
+ * 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
+
+class Section extends LogSupport
+{
+    static final HEADER_PATTERN = ~/----------([^:]*):\(([0-9]*)\/([0-9]*)\)----------/
+    
+    Map streams = new LinkedHashMap()
+    
+    def Section(BufferedReader input) {
+        assert input != null
+        
+        def line
+        
+        // This will break on null or empty line
+        while (line = input.readLine()) {
+            def matcher = HEADER_PATTERN.matcher(line)
+            
+            // Parse out a stream
+            if (matcher.matches()) {
+                def name = matcher[0][1]
+                def lines = matcher[0][2]
+                def chars = matcher[0][3].toInteger()
+                
+                log.info "Stream '$name' $lines lines, $chars characters"
+                
+                char[] buff = new char[chars]
+                int c = input.read(buff)
+                assert c == chars
+                
+                def data = new String(buff)
+                
+                log.info 'Data:' + ('-' * 75) + "\n$data"
+                log.info '-' * 80
+                
+                streams[name] = data
+            }
+        }
+    }
+}
+

Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/Section.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/Section.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/Section.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=auto&rev=502207
==============================================================================
--- geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/TestResult.groovy
(added)
+++ geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/TestResult.groovy
Thu Feb  1 05:23:17 2007
@@ -0,0 +1,138 @@
+/*
+ * 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
+
+/**
+ * Represents a JavaTest test result (the stuff in those .jtr files)
+ */
+class TestResult extends LogSupport
+{
+    String checksum
+    
+    Map desc
+    
+    Map env
+    
+    Map props
+    
+    Map sections
+    
+    String status
+    
+    def TestResult(file) {
+        load(file)
+    }
+    
+    def scanFor(input, 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()
+        
+        log.info "Loading test result from: $file"
+        
+        def input = file.newReader()
+        
+        // Read the header
+        assert input.readLine() == '#Test Results (version 2)'
+        
+        checksum = scanFor(input, '#checksum:').tokenize(':')[1]
+        log.info "Checksum: $checksum"
+        
+        // Read the test description
+        scanFor(input, '#-----testdescription-----')
+        desc = loadProperties(input)
+        log.info 'Description:'
+        desc.each {
+            log.info "    $it"
+        }
+        
+        // Read the environment
+        scanFor(input, '#-----environment-----')
+        env = loadProperties(input)
+        log.info 'Environment:'
+        env.each {
+            log.info "    $it"
+        }
+        
+        // Read the test result properties
+        scanFor(input, '#-----testresult-----')
+        props = loadProperties(input)
+        log.info 'Properties:'
+        props.each {
+            log.info "    $it"
+        }
+        
+        // Load test sections
+        sections = new LinkedHashMap()
+        for (name in props['sections'].tokenize()) {
+            log.info "Section: $name"
+            sections[name] = new Section(input)
+        }
+        
+        //
+        // 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 = scanFor(input, 'test result: ').split(' ', 3)[2]
+        log.info "Status: $status"
+        
+        if (!status) {
+            throw new ParseException("Missing token: $TSTRESULT")
+        }
+    }
+    
+    Map loadProperties(BufferedReader input) {
+        assert input != null
+        
+        // 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 = input.readLine()) {
+            def parts = line.split('=', 2)
+            assert parts.size() == 2
+            
+            props[parts[0]] = parts[1]
+        }
+        
+        return props
+    }
+}
+

Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/TestResult.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/TestResult.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/TestResult.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message