diff mbox series

[v2,07/28] buildman: Test the output with --list-error-boards

Message ID 20200409150840.v2.7.I571a331de630a5dcc7b659f464531e65d55aa94b@changeid
State Accepted
Commit e631a2b48a4501e99f89584e23c34377d5448708
Headers show
Series buildman: Improve summary output | expand

Commit Message

Simon Glass April 9, 2020, 9:08 p.m. UTC
Add a test to cover this flag, which adds the name of each board to each
error/warning line.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v2:
- Move the 'boards' variables to the start of _CheckOutput()

 tools/buildman/test.py | 46 +++++++++++++++++++++++++++++-------------
 1 file changed, 32 insertions(+), 14 deletions(-)

Comments

Simon Glass April 17, 2020, 11:29 p.m. UTC | #1
Add a test to cover this flag, which adds the name of each board to each
error/warning line.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v2:
- Move the 'boards' variables to the start of _CheckOutput()

 tools/buildman/test.py | 46 +++++++++++++++++++++++++++++-------------
 1 file changed, 32 insertions(+), 14 deletions(-)

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/tools/buildman/test.py b/tools/buildman/test.py
index 1377035fbb4..b1435b45c03 100644
--- a/tools/buildman/test.py
+++ b/tools/buildman/test.py
@@ -214,13 +214,15 @@  class TestBuild(unittest.TestCase):
             terminal.EchoPrintTestLines()
         return iter(terminal.GetPrintTestLines())
 
-    def _CheckOutput(self, lines):
+    def _CheckOutput(self, lines, list_error_boards):
         """Check for expected output from the build summary
 
         Args:
             lines: Iterator containing the lines returned from the summary
+            list_error_boards: Adjust the check for output produced with the
+               --list-error-boards flag
         """
-        def add_line_prefix(prefix, error_str):
+        def add_line_prefix(prefix, boards, error_str):
             """Add a prefix to each line of a string
 
             The training \n in error_str is removed before processing
@@ -232,10 +234,17 @@  class TestBuild(unittest.TestCase):
             Returns:
                 New string where each line has the prefix added
             """
+            if boards:
+                boards = '(%s) ' % boards
             lines = error_str.strip().splitlines()
-            new_lines = [prefix + line for line in lines]
+            new_lines = [prefix + boards + line for line in lines]
             return '\n'.join(new_lines)
 
+        boards1234 = 'board1,board2,board3,board4' if list_error_boards else ''
+        boards234 = 'board2,board3,board4' if list_error_boards else ''
+        boards34 = 'board3,board4' if list_error_boards else ''
+        boards4 = 'board4' if list_error_boards else ''
+
         # Upstream commit: no errors
         self.assertEqual(next(lines).text, '01: %s' % commits[0][1])
 
@@ -253,7 +262,8 @@  class TestBuild(unittest.TestCase):
         # Second commit: The warnings should be listed
         line = next(lines)
 
-        self.assertEqual(line.text, add_line_prefix('w+', errors[0]))
+        self.assertEqual(line.text,
+                         add_line_prefix('w+', boards1234, errors[0]))
         self.assertEqual(line.colour, col.MAGENTA)
 
         # Third commit: Still fails
@@ -266,7 +276,7 @@  class TestBuild(unittest.TestCase):
 
         # Expect a compiler error
         line = next(lines)
-        self.assertEqual(line.text, add_line_prefix('+', errors[1]))
+        self.assertEqual(line.text, add_line_prefix('+', boards234, errors[1]))
         self.assertEqual(line.colour, col.RED)
 
         # Fourth commit: Compile errors are fixed, just have warning for board3
@@ -284,11 +294,11 @@  class TestBuild(unittest.TestCase):
 
         # Compile error fixed
         line = next(lines)
-        self.assertEqual(line.text, add_line_prefix('-', errors[1]))
+        self.assertEqual(line.text, add_line_prefix('-', boards234, errors[1]))
         self.assertEqual(line.colour, col.GREEN)
 
         line = next(lines)
-        self.assertEqual(line.text, add_line_prefix('w+', errors[2]))
+        self.assertEqual(line.text, add_line_prefix('w+', boards34, errors[2]))
         self.assertEqual(line.colour, col.MAGENTA)
 
         # Fifth commit
@@ -302,11 +312,11 @@  class TestBuild(unittest.TestCase):
         expect = [expect[0]] + expect[2:]
         expect = '\n'.join(expect)
         line = next(lines)
-        self.assertEqual(line.text, add_line_prefix('+', expect))
+        self.assertEqual(line.text, add_line_prefix('+', boards4, expect))
         self.assertEqual(line.colour, col.RED)
 
         line = next(lines)
-        self.assertEqual(line.text, add_line_prefix('w-', errors[2]))
+        self.assertEqual(line.text, add_line_prefix('w-', boards34, errors[2]))
         self.assertEqual(line.colour, col.CYAN)
 
         # Sixth commit
@@ -319,11 +329,11 @@  class TestBuild(unittest.TestCase):
         expect = [expect[0]] + expect[2:]
         expect = '\n'.join(expect)
         line = next(lines)
-        self.assertEqual(line.text, add_line_prefix('-', expect))
+        self.assertEqual(line.text, add_line_prefix('-', boards4, expect))
         self.assertEqual(line.colour, col.GREEN)
 
         line = next(lines)
-        self.assertEqual(line.text, add_line_prefix('w-', errors[0]))
+        self.assertEqual(line.text, add_line_prefix('w-', boards4, errors[0]))
         self.assertEqual(line.colour, col.CYAN)
 
         # Seventh commit
@@ -335,14 +345,14 @@  class TestBuild(unittest.TestCase):
         expect = expect_str[3:8] + [expect_str[-1]]
         expect = '\n'.join(expect)
         line = next(lines)
-        self.assertEqual(line.text, add_line_prefix('+', expect))
+        self.assertEqual(line.text, add_line_prefix('+', boards4, expect))
         self.assertEqual(line.colour, col.RED)
 
         # Now the warnings lines
         expect = [expect_str[0]] + expect_str[10:12] + [expect_str[9]]
         expect = '\n'.join(expect)
         line = next(lines)
-        self.assertEqual(line.text, add_line_prefix('w+', expect))
+        self.assertEqual(line.text, add_line_prefix('w+', boards4, expect))
         self.assertEqual(line.colour, col.MAGENTA)
 
     def testOutput(self):
@@ -351,7 +361,15 @@  class TestBuild(unittest.TestCase):
         This does a line-by-line verification of the summary output.
         """
         lines = self._SetupTest(show_errors=True)
-        self._CheckOutput(lines)
+        self._CheckOutput(lines, list_error_boards=False)
+
+    def testErrorBoards(self):
+        """Test output with --list-error-boards
+
+        This does a line-by-line verification of the summary output.
+        """
+        lines = self._SetupTest(show_errors=True, list_error_boards=True)
+        self._CheckOutput(lines, list_error_boards=True)
 
     def _testGit(self):
         """Test basic builder operation by building a branch"""