summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2019-05-21 14:08:46 +0100
committerAngelos Evripiotis <angelos.evripiotis@gmail.com>2019-05-21 14:33:19 +0000
commitb25d0c7aa68ce8e114aec4a54002f6708f4e3770 (patch)
tree2a8ad5849e0b86bb333a440fd4b062d40e4a9559
parent6c59e7901a52be961c2a1b671cf2b30f90bc4d0a (diff)
downloadbuildstream-aevri/fix_logging_regex_test.tar.gz
tests/frontend/logging.py: fix error message regexaevri/fix_logging_regex_test
This regex was not matching, and therefore the assert was not doing anything. Fix the regex to match BuildStream's current output. Add a check to make sure that we get exactly the number of expected matches. This means we get an obvious error if the regex stops matching again.
-rw-r--r--tests/frontend/logging.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/frontend/logging.py b/tests/frontend/logging.py
index e7279ac4c..31a2dd909 100644
--- a/tests/frontend/logging.py
+++ b/tests/frontend/logging.py
@@ -109,8 +109,19 @@ def test_failed_build_listing(cli, datafiles):
result = cli.run(project=project, args=['--on-error=continue', 'build', *element_names])
result.assert_main_error(ErrorDomain.STREAM, None)
+ # Check that we re-print the failure summaries only in the "Failure Summary"
+ # section.
+ # e.g.
+ #
+ # Failure Summary
+ # testfail-0.bst:
+ # [00:00:00][44f1b8c3][ build:testfail-0.bst ] FAILURE Running 'commands'
+ #
failure_heading_pos = re.search(r'^Failure Summary$', result.stderr, re.MULTILINE).start()
pipeline_heading_pos = re.search(r'^Pipeline Summary$', result.stderr, re.MULTILINE).start()
failure_summary_range = range(failure_heading_pos, pipeline_heading_pos)
- assert all(m.start() in failure_summary_range and m.end() in failure_summary_range
- for m in re.finditer(r'^\s+testfail-.\.bst.+?\s+Log file', result.stderr, re.MULTILINE))
+ matches = tuple(re.finditer(r'^\s+testfail-.\.bst:$', result.stderr, re.MULTILINE))
+ for m in matches:
+ assert m.start() in failure_summary_range
+ assert m.end() in failure_summary_range
+ assert len(matches) == 3 # each element should be matched once.