]> git.sur5r.net Git - u-boot/commitdiff
test/py: highlight warnings in the log summary
authorStephen Warren <swarren@nvidia.com>
Tue, 20 Feb 2018 19:51:55 +0000 (12:51 -0700)
committerTom Rini <trini@konsulko.com>
Wed, 14 Mar 2018 01:59:26 +0000 (21:59 -0400)
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 <swarren@nvidia.com>
test/py/conftest.py
test/py/multiplexed_log.css
test/py/multiplexed_log.py

index 3fe91e874606b58de55e2da485fd2fa2c377d1f4..83eaca46a908dcf83de55cd20678114ec6f805a6 100644 (file)
@@ -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'):
index 9b7c44fe4de00169a0e76058d40457e211cbec7e..562f69f3b6f7c1c24c8a51f02787a03dd4ee340c 100644 (file)
@@ -70,6 +70,10 @@ pre {
     color: #00ff00
 }
 
+.status-warning {
+    color: #ffff00
+}
+
 .status-skipped {
     color: #ffff00
 }
index 8ca515319ce954e1833a4bfd0a7e2308fe48bf22..a2cfd71746190f9e54cfc8f8f2ba40132be80e1d 100644 (file)
@@ -224,6 +224,7 @@ class Logfile(object):
         self.timestamp_start = self._get_time()
         self.timestamp_prev = self.timestamp_start
         self.timestamp_blocks = []
+        self.seen_warning = False
 
         shutil.copy(mod_dir + '/multiplexed_log.css', os.path.dirname(fn))
         self.f.write('''\
@@ -252,6 +253,7 @@ $(document).ready(function () {
     passed_bcs = passed_bcs.not(":has(.status-xfail)");
     passed_bcs = passed_bcs.not(":has(.status-xpass)");
     passed_bcs = passed_bcs.not(":has(.status-skipped)");
+    passed_bcs = passed_bcs.not(":has(.status-warning)");
     // Hide the passed blocks
     passed_bcs.addClass("hidden");
     // Flip the expand/contract button hiding for those blocks.
@@ -478,8 +480,23 @@ $(document).ready(function () {
             Nothing.
         """
 
+        self.seen_warning = True
         self._note("warning", msg)
 
+    def get_and_reset_warning(self):
+        """Get and reset the log warning flag.
+
+        Args:
+            None
+
+        Returns:
+            Whether a warning was seen since the last call.
+        """
+
+        ret = self.seen_warning
+        self.seen_warning = False
+        return ret
+
     def info(self, msg):
         """Write an informational note to the log file.
 
@@ -542,6 +559,19 @@ $(document).ready(function () {
 
         self._note("status-pass", msg, anchor)
 
+    def status_warning(self, msg, anchor=None):
+        """Write a note to the log file describing test(s) which passed.
+
+        Args:
+            msg: A message describing the passed test(s).
+            anchor: Optional internal link target.
+
+        Returns:
+            Nothing.
+        """
+
+        self._note("status-warning", msg, anchor)
+
     def status_skipped(self, msg, anchor=None):
         """Write a note to the log file describing skipped test(s).