]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
bitbake-selftest: enable bitbake logging to stdout
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 18 Aug 2016 16:55:54 +0000 (19:55 +0300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 19 Aug 2016 15:44:47 +0000 (16:44 +0100)
Now you get the bb logger output for failed tests. This helps debugging
problems. Also, all stdout/stderr data for successful tests is silenced
which makes for less cluttered console output.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bin/bitbake-selftest

index 1e00e33271f1587a91167a5323d7763338f8897e..380e003619ceca39782fe6456e7d44c87369b104 100755 (executable)
@@ -37,6 +37,24 @@ for t in tests:
     __import__(t)
 
 
+# Set-up logging
+class StdoutStreamHandler(logging.StreamHandler):
+    """Special handler so that unittest is able to capture stdout"""
+    def __init__(self):
+        # Override __init__() because we don't want to set self.stream here
+        logging.Handler.__init__(self)
+
+    @property
+    def stream(self):
+        # We want to dynamically write wherever sys.stdout is pointing to
+        return sys.stdout
+
+
+handler = StdoutStreamHandler()
+bb.logger.addHandler(handler)
+bb.logger.setLevel(logging.DEBUG)
+
+
 ENV_HELP = """\
 Environment variables:
   BB_SKIP_NETTESTS      set to 'yes' in order to skip tests using network
@@ -51,4 +69,4 @@ class main(unittest.main):
 
 
 if __name__ == '__main__':
-        main(defaultTest=tests)
+        main(defaultTest=tests, buffer=True)