X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=test%2Fpy%2Fconftest.py;h=e591f5879dcb60ca26f0ecfd9555067bd162e18c;hb=dffd56d1d270e4797e43272a6c9000b8b8aeaf29;hp=6e66a48c15fdad796150467da5d6589bcf5758fb;hpb=2ee87b0c1a5439e4ad6467cb8d5e8fb58922ca4b;p=u-boot diff --git a/test/py/conftest.py b/test/py/conftest.py index 6e66a48c15..e591f5879d 100644 --- a/test/py/conftest.py +++ b/test/py/conftest.py @@ -1,7 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 # Copyright (c) 2015 Stephen Warren # Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved. -# -# SPDX-License-Identifier: GPL-2.0 # Implementation of pytest run-time hook functions. These are invoked by # pytest at certain points during operation, e.g. startup, for each executed @@ -200,7 +199,7 @@ def pytest_configure(config): import u_boot_console_exec_attach console = u_boot_console_exec_attach.ConsoleExecAttach(log, ubconfig) -re_ut_test_list = re.compile(r'_u_boot_list_2_(dm|env)_test_2_\1_test_(.*)\s*$') +re_ut_test_list = re.compile(r'_u_boot_list_2_(.*)_test_2_\1_test_(.*)\s*$') def generate_ut_subtest(metafunc, fixture_name): """Provide parametrization for a ut_subtest fixture. @@ -344,6 +343,7 @@ tests_failed = [] tests_xpassed = [] tests_xfailed = [] tests_skipped = [] +tests_warning = [] tests_passed = [] def pytest_itemcollected(item): @@ -380,6 +380,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 +525,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 +538,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'): @@ -574,7 +586,7 @@ def pytest_runtest_protocol(item, nextitem): # is fixed, if this exception still exists, it will then be logged as # part of the test's stdout. import traceback - print 'Exception occurred while logging runtest status:' + print('Exception occurred while logging runtest status:') traceback.print_exc() # FIXME: Can we force a test failure here?