geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r502806 - /geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/TestResult.groovy
Date Sat, 03 Feb 2007 00:16:18 GMT
Author: jdillon
Date: Fri Feb  2 16:16:18 2007
New Revision: 502806

URL: http://svn.apache.org/viewvc?view=rev&rev=502806
Log:
Better parsing for status

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=502806&r1=502805&r2=502806
==============================================================================
--- 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
Fri Feb  2 16:16:18 2007
@@ -32,8 +32,6 @@
  */
 class TestResult extends LogSupport
 {
-    static final STREAM_HEADER_PATTERN = ~/----------([^:]*):\(([0-9]*)\/([0-9]*)\)----------/
-    
     String checksum
     
     Map testdescription
@@ -50,7 +48,7 @@
         load(file)
     }
     
-    def load(file) {
+    private void load(file) {
         assert file
         
         file = new File("$file").canonicalFile
@@ -129,8 +127,10 @@
             
             def line
             
+            def pattern = ~/----------([^:]*):\(([0-9]*)\/([0-9]*)\)----------/
+            
             while (line = readLine()) {
-                def matcher = STREAM_HEADER_PATTERN.matcher(line)
+                def matcher = pattern.matcher(line)
                 
                 // Find the stream header
                 if (matcher.matches()) {
@@ -188,13 +188,46 @@
             def sections = new LinkedHashMap()
             
             testresult['sections'].tokenize().each { name ->
-                def section = loadSection(name)
-                sections[name] = section
+                sections[name] = loadSection(name)
             }
             
             return sections
         }
         
+        def loadStatus = {
+            log.debug "Loading status..."
+            
+            def status = new Expando()
+            status.passed = false
+            status.failed = false
+            status.error = false
+            
+            def line = scan('test result: ').split(' ', 3)[2]
+            
+            def pattern = ~/([^.]*)\.(.*)/
+            def matcher = pattern.matcher(line)
+            assert matcher.matches()
+            
+            status.text = matcher[0][1].toUpperCase()
+            status.reason = matcher[0][2].trim()
+            
+            switch (status.text) {
+                case 'PASSED':
+                    status.passed = true
+                    break
+                
+                case 'FAILED':
+                    status.failed = true
+                    break
+                
+                case 'ERROR':
+                    status.error = true
+                    break
+            }
+            
+            return status
+        }
+        
         try {
             assert readLine() == '#Test Results (version 2)'
             
@@ -208,7 +241,11 @@
             
             sections = loadSections()
             
-            status = scan('test result: ').split(' ', 3)[2]
+            status = loadStatus()
+            
+            //
+            // TODO: Maybe sanity check the checksum for final validation of content?
+            //
         }
         finally {
             input.close()



Mime
View raw message