[Concept,05/18] buildman: Move OUTCOME_* constants to outcome module

Message ID 20260110200828.168672-6-sjg@u-boot.org
State New
Headers
Series buildman: Split up the enormous Builder class |

Commit Message

Simon Glass Jan. 10, 2026, 8:08 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Move the OUTCOME_OK, OUTCOME_WARNING, OUTCOME_ERROR, and OUTCOME_UNKNOWN
constants from builder.py to outcome.py alongside the Outcome class.

Update builder.py and test_builder.py to import from the new location.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 tools/buildman/builder.py      |  6 ++----
 tools/buildman/outcome.py      |  5 ++++-
 tools/buildman/test_builder.py | 32 +++++++++++++++++++-------------
 3 files changed, 25 insertions(+), 18 deletions(-)
  

Patch

diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index 94552bf62ca..96976f513e8 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -21,7 +21,8 @@  import threading
 
 from buildman import builderthread
 from buildman.cfgutil import Config, process_config
-from buildman.outcome import Outcome
+from buildman.outcome import (Outcome, OUTCOME_OK, OUTCOME_WARNING,
+                              OUTCOME_ERROR, OUTCOME_UNKNOWN)
 from u_boot_pylib import command
 from u_boot_pylib import gitutil
 from u_boot_pylib import terminal
@@ -135,9 +136,6 @@  ErrLine = collections.namedtuple('ErrLine', 'char,brds,errline')
 #   unknown: List of boards that were not built
 BoardStatus = collections.namedtuple('BoardStatus', 'ok,warn,err,new,unknown')
 
-# Possible build outcomes
-OUTCOME_OK, OUTCOME_WARNING, OUTCOME_ERROR, OUTCOME_UNKNOWN = list(range(4))
-
 # Translate a commit subject into a valid filename (and handle unicode)
 trans_valid_chars = str.maketrans('/: ', '---')
 
diff --git a/tools/buildman/outcome.py b/tools/buildman/outcome.py
index 4f8bc9a0bae..373740cd94b 100644
--- a/tools/buildman/outcome.py
+++ b/tools/buildman/outcome.py
@@ -1,7 +1,10 @@ 
 # SPDX-License-Identifier: GPL-2.0+
 # Copyright (c) 2013 The Chromium OS Authors.
 
-"""Outcome class for buildman build results"""
+"""Outcome class and constants for buildman build results"""
+
+# Build-outcome codes
+OUTCOME_OK, OUTCOME_WARNING, OUTCOME_ERROR, OUTCOME_UNKNOWN = list(range(4))
 
 
 class Outcome:
diff --git a/tools/buildman/test_builder.py b/tools/buildman/test_builder.py
index fd60767bca0..b92e0be18be 100644
--- a/tools/buildman/test_builder.py
+++ b/tools/buildman/test_builder.py
@@ -12,6 +12,8 @@  from unittest import mock
 
 from buildman import builder
 from buildman import builderthread
+from buildman.outcome import (OUTCOME_OK, OUTCOME_WARNING, OUTCOME_ERROR,
+                              OUTCOME_UNKNOWN)
 from u_boot_pylib import gitutil
 from u_boot_pylib import terminal
 
@@ -358,12 +360,16 @@  class TestShowNotBuilt(unittest.TestCase):
         outcome.err_lines = err_lines if err_lines else []
         return outcome
 
+    def _show_not_built(self, board_selected, board_dict):
+        """Helper to call Builder._show_not_built"""
+        builder.Builder._show_not_built(board_selected, board_dict)
+
     def test_all_boards_built(self):
         """Test when all selected boards were built successfully"""
         board_selected = {'board1': None, 'board2': None}
         board_dict = {
-            'board1': self._make_outcome(builder.OUTCOME_OK),
-            'board2': self._make_outcome(builder.OUTCOME_OK),
+            'board1': self._make_outcome(OUTCOME_OK),
+            'board2': self._make_outcome(OUTCOME_OK),
         }
 
         terminal.get_print_test_lines()  # Clear
@@ -377,9 +383,9 @@  class TestShowNotBuilt(unittest.TestCase):
         """Test when some boards have OUTCOME_UNKNOWN (e.g. missing toolchain)"""
         board_selected = {'board1': None, 'board2': None, 'board3': None}
         board_dict = {
-            'board1': self._make_outcome(builder.OUTCOME_OK),
-            'board2': self._make_outcome(builder.OUTCOME_UNKNOWN),
-            'board3': self._make_outcome(builder.OUTCOME_UNKNOWN),
+            'board1': self._make_outcome(OUTCOME_OK),
+            'board2': self._make_outcome(OUTCOME_UNKNOWN),
+            'board3': self._make_outcome(OUTCOME_UNKNOWN),
         }
 
         terminal.get_print_test_lines()  # Clear
@@ -396,8 +402,8 @@  class TestShowNotBuilt(unittest.TestCase):
         """Test when all boards have OUTCOME_UNKNOWN"""
         board_selected = {'board1': None, 'board2': None}
         board_dict = {
-            'board1': self._make_outcome(builder.OUTCOME_UNKNOWN),
-            'board2': self._make_outcome(builder.OUTCOME_UNKNOWN),
+            'board1': self._make_outcome(OUTCOME_UNKNOWN),
+            'board2': self._make_outcome(OUTCOME_UNKNOWN),
         }
 
         terminal.get_print_test_lines()  # Clear
@@ -413,8 +419,8 @@  class TestShowNotBuilt(unittest.TestCase):
         """Test that build errors (not toolchain) are not counted as 'not built'"""
         board_selected = {'board1': None, 'board2': None}
         board_dict = {
-            'board1': self._make_outcome(builder.OUTCOME_OK),
-            'board2': self._make_outcome(builder.OUTCOME_ERROR,
+            'board1': self._make_outcome(OUTCOME_OK),
+            'board2': self._make_outcome(OUTCOME_ERROR,
                                          ['error: some build error']),
         }
 
@@ -429,10 +435,10 @@  class TestShowNotBuilt(unittest.TestCase):
         """Test that toolchain errors are counted as 'not built'"""
         board_selected = {'board1': None, 'board2': None, 'board3': None}
         board_dict = {
-            'board1': self._make_outcome(builder.OUTCOME_OK),
-            'board2': self._make_outcome(builder.OUTCOME_ERROR,
+            'board1': self._make_outcome(OUTCOME_OK),
+            'board2': self._make_outcome(OUTCOME_ERROR,
                                          ['Tool chain error for arm: not found']),
-            'board3': self._make_outcome(builder.OUTCOME_ERROR,
+            'board3': self._make_outcome(OUTCOME_ERROR,
                                          ['error: some build error']),
         }
 
@@ -451,7 +457,7 @@  class TestShowNotBuilt(unittest.TestCase):
         """Test that boards missing from board_dict are counted as 'not built'"""
         board_selected = {'board1': None, 'board2': None, 'board3': None}
         board_dict = {
-            'board1': self._make_outcome(builder.OUTCOME_OK),
+            'board1': self._make_outcome(OUTCOME_OK),
             # board2 and board3 are not in board_dict
         }