Re: [PATCH kvm-unit-tests v2 10/12] run_tests: print summary

Radim Krčmář
2015-12-18T12:24:18Z

2015-12-17 13:55-0600, Andrew Jones:
> On Thu, Dec 17, 2015 at 06:53:41PM +0100, Radim Krčmář wrote:
>> Might be interesting and hopefully won't break too many scripts.
>>
>> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
>> ---
>> v2:
>> - don't print "0 unexpected failures" in run_tests' summary. [Drew]
>> (This could have been done in lib/report, but I'm not sure why we want
>> to always print it in the summary, so I've kept it there.)
>> - use $testname
>> - don't buffer the output (a serious bug in v1)
>> - worse performance (reads the output of all tests)
>>
>> diff --git a/run_tests.sh b/run_tests.sh
>> + __echo_last_log | sed 'x;$s/^SUMMARY: //;ta;$s/.*//p;d;
>> + :a s/, 0 unexpected failures//;s/^/ (/;s/$/)/'
>
> This sed is way beyond my skillz. I would have just done the following
> at the expense of an extra pipe :-)
>
> tac test.log | grep -m1 '^SUMMARY:' | sed 's/.*: \(.*\),.*/\1/'

This won't print a newline in case there is no summary, but yeah, I will
limit myself to the well known 's' command.

(tail won't buffer the whole file and `head` instead of -m is POSIX.)