From: Simon Glass <simon.glass@canonical.com> Move the summary printing code from build_boards() into a separate _print_build_summary() method. This improves readability and makes the summary logic easier to test independently. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- tools/buildman/builder.py | 56 ++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index d24fad9a550..3c0af07d624 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -2214,29 +2214,37 @@ class Builder: # Wait until we have processed all output self.out_queue.join() if not self._ide: - tprint() - - msg = f'Completed: {self.count} total built' - if self.already_done or self.kconfig_reconfig: - parts = [] - if self.already_done: - parts.append(f'{self.already_done} previously') - if self.already_done != self.count: - parts.append(f'{self.count - self.already_done} newly') - if self.kconfig_reconfig: - parts.append(f'{self.kconfig_reconfig} reconfig') - msg += ' (' + ', '.join(parts) + ')' - duration = datetime.now() - self._start_time - if duration > timedelta(microseconds=1000000): - if duration.microseconds >= 500000: - duration = duration + timedelta(seconds=1) - duration -= timedelta(microseconds=duration.microseconds) - rate = float(self.count) / duration.total_seconds() - msg += f', duration {duration}, rate {rate:1.2f}' - tprint(msg) - if self.thread_exceptions: - tprint( - f'Failed: {len(self.thread_exceptions)} thread exceptions', - colour=self.col.RED) + self._print_build_summary() return (self.fail, self.warned, self.thread_exceptions) + + def _print_build_summary(self): + """Print a summary of the build results + + Show the number of boards built, how many were already done, duration + and build rate. Also show any thread exceptions that occurred. + """ + tprint() + + msg = f'Completed: {self.count} total built' + if self.already_done or self.kconfig_reconfig: + parts = [] + if self.already_done: + parts.append(f'{self.already_done} previously') + if self.already_done != self.count: + parts.append(f'{self.count - self.already_done} newly') + if self.kconfig_reconfig: + parts.append(f'{self.kconfig_reconfig} reconfig') + msg += ' (' + ', '.join(parts) + ')' + duration = datetime.now() - self._start_time + if duration > timedelta(microseconds=1000000): + if duration.microseconds >= 500000: + duration = duration + timedelta(seconds=1) + duration -= timedelta(microseconds=duration.microseconds) + rate = float(self.count) / duration.total_seconds() + msg += f', duration {duration}, rate {rate:1.2f}' + tprint(msg) + if self.thread_exceptions: + tprint( + f'Failed: {len(self.thread_exceptions)} thread exceptions', + colour=self.col.RED) -- 2.43.0