From: Naftaly RALAMBOARIVONY <[email protected]>

Add a command line option to make patchtest return a non-zero exit
status when a test fails.

This keeps the current default behavior unchanged while allowing calling
scripts and shells to detect test failures through the process exit
status when explicitly requested.

Signed-off-by: Naftaly RALAMBOARIVONY <[email protected]>
---
 meta/lib/patchtest/patchtest_parser.py | 3 +++
 scripts/patchtest                      | 8 ++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/meta/lib/patchtest/patchtest_parser.py 
b/meta/lib/patchtest/patchtest_parser.py
index 2a11cb76c2..ba5a171e27 100644
--- a/meta/lib/patchtest/patchtest_parser.py
+++ b/meta/lib/patchtest/patchtest_parser.py
@@ -73,6 +73,9 @@ class PatchtestParser(object):
                             action='store_true', 
                             help='Enable logging to a file matching the target 
patch name with ".testresult" appended')
 
+        parser.add_argument('--error-on-failure',
+                            action='store_true',
+                            help='Return non-zero exit status if a test fails')
 
         return parser
 
diff --git a/scripts/patchtest b/scripts/patchtest
index 9218db232a..653f2b217a 100755
--- a/scripts/patchtest
+++ b/scripts/patchtest
@@ -183,6 +183,7 @@ def print_result_message(preresult, postresult):
     
print("----------------------------------------------------------------------\n")
 
 def main():
+    ret = 0
     tmp_patch = False
     patch_path = PatchtestParser.patch_path
     log_results = PatchtestParser.log_results
@@ -214,13 +215,16 @@ def main():
 
         try:
             if log_path:
-                run(patch, log_path)
+                ret = run(patch, log_path)
             else:
-                run(patch)
+                ret = run(patch)
         finally:
             if tmp_patch:
                 os.remove(patch)
 
+        if PatchtestParser.error_on_failure and ret != 0:
+            return ret
+
 if __name__ == '__main__':
     ret = 1
 
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#233412): 
https://lists.openembedded.org/g/openembedded-core/message/233412
Mute This Topic: https://lists.openembedded.org/mt/118385556/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to