]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
scripts/patchtest: simplify _runner()
authorTrevor Gamblin <tgamblin@baylibre.com>
Thu, 18 Jun 2026 20:36:28 +0000 (16:36 -0400)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 29 Jun 2026 09:37:38 +0000 (10:37 +0100)
- Use the test suite's countTestCases() method directly instead of
  creating a variable
- Simplify return logic - we still want to fail early if there are no
  test suites to use, but otherwise we can reduce it to a single return
  value determination based on the result of runner.run()
- Add a newline above where the 'runner' variable is initialized

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/patchtest

index ff8e8b11bd50bf3534f96c663b4ed2a8815893ea..795fad511fa77a20dc7e276be31be1e9c45e91bb 100755 (executable)
@@ -123,11 +123,11 @@ def _runner(resultklass, prefix=None):
         pattern=PatchtestParser.pattern,
         top_level_dir=PatchtestParser.topdir,
     )
-    ntc = suite.countTestCases()
 
     # if there are no test cases, just quit
-    if not ntc:
+    if not suite.countTestCases():
         return 2
+
     runner = unittest.TextTestRunner(resultclass=resultklass, verbosity=0)
 
     try:
@@ -135,11 +135,8 @@ def _runner(resultklass, prefix=None):
     except:
         logger.error(traceback.print_exc())
         logger.error('patchtest: something went wrong')
-        return 1
-    if result.test_failure or result.test_error:
-        return 1 
 
-    return 0
+    return 1 if (result.test_failure or result.test_error) else 0
 
 def run(patch, logfile=None):
     """ Load, setup and run pre and post-merge tests """