kunit_tool: Move log printing out of kunit_parser

Currently, kunit_parser will print a test log in parse_run_tests. This
means that, in kunit_test, there is a lot of confusing output from the
included test logs.

This change makes kunit_parser write its log to a string, which may then
optinally be printed by its caller. In this case, we make the main
'kunit.py' print out the test log when running tests, but to not make
kunit_test do so, as to not clutter the unittest output.

In doing this, the kunit_parser.TestResult type is changed to a class
(with an additional 'pretty_log' function which writes to
TestResult.log_lines), replacing the old namedtuple
implemenatation. There is also an additional
TestResult.print_pretty_log() function to print this log.

Signed-off-by: David Gow <davidgow@google.com>
Change-Id: Ib6c70f9749cf3daf513c150d472b58903aff0202
2 files changed