From: Quentin Schulz <[email protected]>

This will allow use to specify which messages we want to see later on.
This will be useful for using this script with b4 for example which
expects output on stdout/stderr only when an error happened.

To that end, success string is set to the info level, warning string to
warning level and error to error level.

The summary is printed with the appropriate log level, error if warnings
or errors were found, info otherwise.

Signed-off-by: Quentin Schulz <[email protected]>
---
 scripts/patchtest | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/scripts/patchtest b/scripts/patchtest
index 
9218db232a77516d2a8bdcd967521b884f0de89d..bcd48dbcc39573d7abd3247bc34cb9ac8a8a5c2e
 100755
--- a/scripts/patchtest
+++ b/scripts/patchtest
@@ -82,7 +82,7 @@ def getResult(patch, mergepatch, logfile=None):
             fail_str = '{}: {}: {} ({})'.format(self.fail,
             test_description, json.loads(str(err[1]))["issue"],
             test.id())
-            print(fail_str)
+            logger.error(fail_str)
             if logfile:
                 with open(logfile, "a") as f:
                     f.write(fail_str + "\n")
@@ -94,7 +94,7 @@ def getResult(patch, mergepatch, logfile=None):
             "non-AUH").replace("presence format", "presence")
             success_str = '{}: {} ({})'.format(self.success,
             test_description, test.id())
-            print(success_str)
+            logger.info(success_str)
             if logfile:
                 with open(logfile, "a") as f:
                     f.write(success_str + "\n")
@@ -107,7 +107,7 @@ def getResult(patch, mergepatch, logfile=None):
             skip_str = '{}: {}: {} ({})'.format(self.skip,
             test_description, json.loads(str(reason))["issue"],
             test.id())
-            print(skip_str)
+            logger.warning(skip_str)
             if logfile:
                 with open(logfile, "a") as f:
                     f.write(skip_str + "\n")
@@ -169,18 +169,22 @@ def run(patch, logfile=None):
     return premerge_result or postmerge_result
 
 def print_result_message(preresult, postresult):
-    
print("----------------------------------------------------------------------\n")
     if preresult == 2 and postresult == 2:
+        
logger.error("----------------------------------------------------------------------\n")
         logger.error(
             "patchtest: No test cases found - did you specify the correct 
suite directory?"
         )
+        
logger.error("----------------------------------------------------------------------\n")
     if preresult == 1 or postresult == 1:
+        
logger.error("----------------------------------------------------------------------\n")
         logger.error(
             "WARNING: patchtest: At least one patchtest caused a failure or an 
error - please check https://wiki.yoctoproject.org/wiki/Patchtest for further 
guidance"
         )
+        
logger.error("----------------------------------------------------------------------\n")
     else:
+        
logger.info("----------------------------------------------------------------------\n")
         logger.info("OK: patchtest: All patchtests passed")
-    
print("----------------------------------------------------------------------\n")
+        
logger.info("----------------------------------------------------------------------\n")
 
 def main():
     tmp_patch = False

-- 
2.48.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#210660): 
https://lists.openembedded.org/g/openembedded-core/message/210660
Mute This Topic: https://lists.openembedded.org/mt/110973475/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to