bitbake: bitbake-selftest: enable bitbake logging to stdout

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.

(Bitbake rev: ea19972a16f7639f944823d1d8a7728105460136)

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Markus Lehtonen 2016-08-18 19:55:54 +03:00 committed by Richard Purdie
parent 9cce855f47
commit 4093f0bad2
1 changed files with 19 additions and 1 deletions

View File

@ -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)