diff mbox series

kunit: tool: don't print out test statuses w/ 0s in summary

Message ID 20220407223019.2066361-1-dlatypov@google.com (mailing list archive)
State New
Delegated to: Brendan Higgins
Headers show
Series kunit: tool: don't print out test statuses w/ 0s in summary | expand

Commit Message

Daniel Latypov April 7, 2022, 10:30 p.m. UTC
Before:
> Testing complete. Passed: 137, Failed: 0, Crashed: 0, Skipped: 36, Errors: 0

After:
> Testing complete. Passed: 137, Skipped: 36

Even with our current set of statuses, the output is a bit verbose.
It could get worse in the future if we add more (e.g. timeout, kasan).
Let's only print the relevant ones.

I had previously been sympathetic to the argument that always
printing out all the statuses would make it easier to parse results.
But now we have commit acd8e8407b8f ("kunit: Print test statistics on
failure"), there are test counts printed out in the raw output.
We don't currently print out an overall total across all suites, but it
would be easy to add, if we see a need for that.

Signed-off-by: Daniel Latypov <dlatypov@google.com>
---
 tools/testing/kunit/kunit_parser.py | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)


base-commit: b04d1a8dc7e7ff7ca91a20bef053bcc04265d83a

Comments

David Gow April 8, 2022, 3:48 a.m. UTC | #1
On Fri, Apr 8, 2022 at 6:30 AM Daniel Latypov <dlatypov@google.com> wrote:
>
> Before:
> > Testing complete. Passed: 137, Failed: 0, Crashed: 0, Skipped: 36, Errors: 0
>
> After:
> > Testing complete. Passed: 137, Skipped: 36
>
> Even with our current set of statuses, the output is a bit verbose.
> It could get worse in the future if we add more (e.g. timeout, kasan).
> Let's only print the relevant ones.
>
> I had previously been sympathetic to the argument that always
> printing out all the statuses would make it easier to parse results.
> But now we have commit acd8e8407b8f ("kunit: Print test statistics on
> failure"), there are test counts printed out in the raw output.
> We don't currently print out an overall total across all suites, but it
> would be easy to add, if we see a need for that.
>
> Signed-off-by: Daniel Latypov <dlatypov@google.com>
> ---

Looks good to me. I agree that we should add a total, too. I was
thinking of adding one anyway, but now there's more space for it, I've
just sent a patch out.

Reviewed-by: David Gow <davidgow@google.com>

Cheers,
-- David
Daniel Latypov April 8, 2022, 3:54 a.m. UTC | #2
On Thu, Apr 7, 2022 at 10:48 PM David Gow <davidgow@google.com> wrote:
>
> On Fri, Apr 8, 2022 at 6:30 AM Daniel Latypov <dlatypov@google.com> wrote:
> >
> > Before:
> > > Testing complete. Passed: 137, Failed: 0, Crashed: 0, Skipped: 36, Errors: 0
> >
> > After:
> > > Testing complete. Passed: 137, Skipped: 36
> >
> > Even with our current set of statuses, the output is a bit verbose.
> > It could get worse in the future if we add more (e.g. timeout, kasan).
> > Let's only print the relevant ones.
> >
> > I had previously been sympathetic to the argument that always
> > printing out all the statuses would make it easier to parse results.
> > But now we have commit acd8e8407b8f ("kunit: Print test statistics on
> > failure"), there are test counts printed out in the raw output.
> > We don't currently print out an overall total across all suites, but it
> > would be easy to add, if we see a need for that.
> >
> > Signed-off-by: Daniel Latypov <dlatypov@google.com>
> > ---
>
> Looks good to me. I agree that we should add a total, too. I was
> thinking of adding one anyway, but now there's more space for it, I've
> just sent a patch out.

I was specifically referring to the test statistics in the kernel output.
We print out the counts per suite, but we don't print out the total count.

But a total in the kunit.py parsed output might be useful as well.

>
> Reviewed-by: David Gow <davidgow@google.com>
>
> Cheers,
> -- David
diff mbox series

Patch

diff --git a/tools/testing/kunit/kunit_parser.py b/tools/testing/kunit/kunit_parser.py
index 807ed2bd6832..957907105429 100644
--- a/tools/testing/kunit/kunit_parser.py
+++ b/tools/testing/kunit/kunit_parser.py
@@ -94,11 +94,10 @@  class TestCounts:
 	def __str__(self) -> str:
 		"""Returns the string representation of a TestCounts object.
 		"""
-		return ('Passed: ' + str(self.passed) +
-			', Failed: ' + str(self.failed) +
-			', Crashed: ' + str(self.crashed) +
-			', Skipped: ' + str(self.skipped) +
-			', Errors: ' + str(self.errors))
+		statuses = [('Passed', self.passed), ('Failed', self.failed),
+			('Crashed', self.crashed), ('Skipped', self.skipped),
+			('Errors', self.errors)]
+		return ', '.join('{}: {}'.format(s, n) for s, n in statuses if n > 0)
 
 	def total(self) -> int:
 		"""Returns the total number of test cases within a test