[oe-commits] [openembedded-core] 03/28: oeqa/logparser: Further simplification/clarification

git at git.openembedded.org git at git.openembedded.org
Wed Jan 30 22:00:05 UTC 2019


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit e833972113e4c0844a731ce51e21ba2e6a172d07
Author: Richard Purdie <richard.purdie at linuxfoundation.org>
AuthorDate: Tue Jan 29 13:00:41 2019 +0000

    oeqa/logparser: Further simplification/clarification
    
    Rename the paster to be ptest specific and apply some further cleanups
    to the code to simplify and clarify what its doing.
    
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/lib/oeqa/runtime/cases/ptest.py |  6 +++---
 meta/lib/oeqa/utils/logparser.py     | 36 ++++++++++++++++--------------------
 2 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/meta/lib/oeqa/runtime/cases/ptest.py b/meta/lib/oeqa/runtime/cases/ptest.py
index ebef3f9..1ce22a0 100644
--- a/meta/lib/oeqa/runtime/cases/ptest.py
+++ b/meta/lib/oeqa/runtime/cases/ptest.py
@@ -6,13 +6,13 @@ from oeqa.core.decorator.depends import OETestDepends
 from oeqa.core.decorator.oeid import OETestID
 from oeqa.core.decorator.data import skipIfNotFeature
 from oeqa.runtime.decorator.package import OEHasPackage
-from oeqa.utils.logparser import Lparser, Result
+from oeqa.utils.logparser import PtestParser, Result
 
 class PtestRunnerTest(OERuntimeTestCase):
 
     # a ptest log parser
     def parse_ptest(self, logfile):
-        parser = Lparser()
+        parser = PtestParser()
         result = Result()
 
         with open(logfile, errors='replace') as f:
@@ -20,7 +20,7 @@ class PtestRunnerTest(OERuntimeTestCase):
                 result_tuple = parser.parse_line(line)
                 if not result_tuple:
                     continue
-                result_tuple = line_type, category, status, name = parser.parse_line(line)
+                line_type, category, status, name = result_tuple
 
                 if line_type == 'section' and status == 'begin':
                     current_section = name
diff --git a/meta/lib/oeqa/utils/logparser.py b/meta/lib/oeqa/utils/logparser.py
index 328baee..0807093 100644
--- a/meta/lib/oeqa/utils/logparser.py
+++ b/meta/lib/oeqa/utils/logparser.py
@@ -6,35 +6,31 @@ import re
 from . import ftools
 
 # A parser that can be used to identify weather a line is a test result or a section statement.
-class Lparser(object):
+class PtestParser(object):
 
-    def __init__(self, **kwargs):
+    def __init__(self):
 
         self.test_regex = {}
-        self.test_regex[0] = {}
-        self.test_regex[0]['pass'] = re.compile(r"^PASS:(.+)")
-        self.test_regex[0]['fail'] = re.compile(r"^FAIL:(.+)")
-        self.test_regex[0]['skip'] = re.compile(r"^SKIP:(.+)")
+        self.test_regex['pass'] = re.compile(r"^PASS:(.+)")
+        self.test_regex['fail'] = re.compile(r"^FAIL:(.+)")
+        self.test_regex['skip'] = re.compile(r"^SKIP:(.+)")
 
         self.section_regex = {}
-        self.section_regex[0] = {}
-        self.section_regex[0]['begin'] = re.compile(r"^BEGIN: .*/(.+)/ptest")
-        self.section_regex[0]['end'] = re.compile(r"^END: .*/(.+)/ptest")
+        self.section_regex['begin'] = re.compile(r"^BEGIN: .*/(.+)/ptest")
+        self.section_regex['end'] = re.compile(r"^END: .*/(.+)/ptest")
 
     # Parse a line and return a tuple containing the type of result (test/section) and its category, status and name
     def parse_line(self, line):
 
-        for test_category, test_status_list in self.test_regex.items():
-            for test_status, status_regex in test_status_list.items():
-                test_name = status_regex.search(line)
-                if test_name:
-                    return ['test', test_category, test_status, test_name.group(1)]
-
-        for section_category, section_status_list in self.section_regex.items():
-            for section_status, status_regex in section_status_list.items():
-                section_name = status_regex.search(line)
-                if section_name:
-                    return ['section', section_category, section_status, section_name.group(1)]
+        for test_status, status_regex in test_status_list.items():
+            test_name = status_regex.search(line)
+            if test_name:
+                return ['test', test_category, test_status, test_name.group(1)]
+
+        for section_status, status_regex in section_status_list.items():
+            section_name = status_regex.search(line)
+            if section_name:
+                return ['section', section_category, section_status, section_name.group(1)]
         return None
 
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list