diff mbox series

[3/7] scripts/patchtest: simplify _runner()

Message ID 20260618203632.131125-4-tgamblin@baylibre.com
State New
Headers show
Series patchtest: cleanups and fixes, part 1 | expand

Commit Message

Trevor Gamblin June 18, 2026, 8:36 p.m. UTC
- 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>
---
 scripts/patchtest | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/scripts/patchtest b/scripts/patchtest
index ff8e8b11bd..795fad511f 100755
--- a/scripts/patchtest
+++ b/scripts/patchtest
@@ -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 """