From patchwork Sun Apr 5 15:21:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 237189 List-Id: U-Boot discussion From: sjg at chromium.org (Simon Glass) Date: Sun, 5 Apr 2020 09:21:16 -0600 Subject: [PATCH 07/22] buildman: Test the output with --list-error-boards In-Reply-To: <20200405152131.98147-1-sjg@chromium.org> References: <20200405152131.98147-1-sjg@chromium.org> Message-ID: <20200405092116.7.I571a331de630a5dcc7b659f464531e65d55aa94b@changeid> Add a test to cover this flag, which adds the name of each board to each error/warning line. Signed-off-by: Simon Glass --- tools/buildman/test.py | 46 +++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/tools/buildman/test.py b/tools/buildman/test.py index 1377035fbb4..763943ca76a 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,13 +234,20 @@ 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) # Upstream commit: no errors self.assertEqual(next(lines).text, '01: %s' % commits[0][1]) + 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 '' + # Second commit: all archs should fail with warnings self.assertEqual(next(lines).text, '02: %s' % commits[1][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"""