summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-04-10 00:08:32 +0300
committerSimon Glass <sjg@chromium.org>2020-04-21 15:33:47 +0300
commitce558db34ba762da260104a777092e8150f6f46a (patch)
tree3fe9a9e9d9d20420d8f438a9e3260b485a3b1d4d /tools
parentaf43065f8def868e81c6b20b7c1ee7874bdcf0fb (diff)
downloadu-boot-ce558db34ba762da260104a777092e8150f6f46a.tar.xz
buildman: Split out testOutput() into separate functions
We want to add a few more tests similar to testOutput(). Split its logic into a function which runs buildman to get the output and another which checks the output. This will make it easier to reuse the code. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/buildman/test.py34
1 files changed, 28 insertions, 6 deletions
diff --git a/tools/buildman/test.py b/tools/buildman/test.py
index b2f7e1edf7..c9c7a05ca6 100644
--- a/tools/buildman/test.py
+++ b/tools/buildman/test.py
@@ -178,10 +178,17 @@ class TestBuild(unittest.TestCase):
expect += col.Color(expected_colour, ' %s' % board)
self.assertEqual(text, expect)
- def testOutput(self):
- """Test basic builder operation and output
+ def _SetupTest(self, echo_lines=False, **kwdisplay_args):
+ """Set up the test by running a build and summary
- This does a line-by-line verification of the summary output.
+ Args:
+ echo_lines: True to echo lines to the terminal to aid test
+ development
+ kwdisplay_args: Dict of arguemnts to pass to
+ Builder.SetDisplayOptions()
+
+ Returns:
+ Iterator containing the output lines, each a PrintLine() object
"""
build = builder.Builder(self.toolchains, self.base_dir, None, 1, 2,
checkout=False, show_unknown=False)
@@ -201,11 +208,18 @@ class TestBuild(unittest.TestCase):
# We should get two starting messages, then an update for every commit
# built.
self.assertEqual(count, len(commits) * len(boards) + 2)
- build.SetDisplayOptions(show_errors=True);
+ build.SetDisplayOptions(**kwdisplay_args);
build.ShowSummary(self.commits, board_selected)
- #terminal.EchoPrintTestLines()
- lines = iter(terminal.GetPrintTestLines())
+ if echo_lines:
+ terminal.EchoPrintTestLines()
+ return iter(terminal.GetPrintTestLines())
+
+ def _CheckOutput(self, lines):
+ """Check for expected output from the build summary
+ Args:
+ lines: Iterator containing the lines returned from the summary
+ """
# Upstream commit: no errors
self.assertEqual(next(lines).text, '01: %s' % commits[0][1])
@@ -320,6 +334,14 @@ class TestBuild(unittest.TestCase):
'\n'.join(expect).replace('\n', '\nw+'))
self.assertEqual(line.colour, col.MAGENTA)
+ def testOutput(self):
+ """Test basic builder operation and output
+
+ This does a line-by-line verification of the summary output.
+ """
+ lines = self._SetupTest(show_errors=True)
+ self._CheckOutput(lines)
+
def _testGit(self):
"""Test basic builder operation by building a branch"""
options = Options()