From 32090e5070845564e36c9c5ccc3dc708ece80298 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Tue, 20 Feb 2018 12:51:55 -0700 Subject: test/py: highlight warnings in the log summary Currently, if a test emits a warning message but otherwise passes, there's no indication of this in the log summary, which can lead to warnings being missed. Enhance the test logic to explicitly mention warnings in otherwise passing tests, and not to collapse the log sections for tests with warnings, so that they're more easily seen when scanning the log. Signed-off-by: Stephen Warren --- test/py/conftest.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'test/py/conftest.py') diff --git a/test/py/conftest.py b/test/py/conftest.py index 3fe91e8746..83eaca46a9 100644 --- a/test/py/conftest.py +++ b/test/py/conftest.py @@ -344,6 +344,7 @@ tests_failed = [] tests_xpassed = [] tests_xfailed = [] tests_skipped = [] +tests_warning = [] tests_passed = [] def pytest_itemcollected(item): @@ -380,6 +381,11 @@ def cleanup(): if log: with log.section('Status Report', 'status_report'): log.status_pass('%d passed' % len(tests_passed)) + if tests_warning: + log.status_warning('%d passed with warning' % len(tests_warning)) + for test in tests_warning: + anchor = anchors.get(test, None) + log.status_warning('... ' + test, anchor) if tests_skipped: log.status_skipped('%d skipped' % len(tests_skipped)) for test in tests_skipped: @@ -520,7 +526,9 @@ def pytest_runtest_protocol(item, nextitem): A list of pytest reports (test result data). """ + log.get_and_reset_warning() reports = runtestprotocol(item, nextitem=nextitem) + was_warning = log.get_and_reset_warning() # In pytest 3, runtestprotocol() may not call pytest_runtest_setup() if # the test is skipped. That call is required to create the test's section @@ -531,9 +539,14 @@ def pytest_runtest_protocol(item, nextitem): start_test_section(item) failure_cleanup = False - test_list = tests_passed - msg = 'OK' - msg_log = log.status_pass + if not was_warning: + test_list = tests_passed + msg = 'OK' + msg_log = log.status_pass + else: + test_list = tests_warning + msg = 'OK (with warning)' + msg_log = log.status_warning for report in reports: if report.outcome == 'failed': if hasattr(report, 'wasxfail'): -- cgit v1.2.3