apenwarr/wvtest — pull request #1 by wentasah (2012-08-15 15:40:23+00:00)
Title: wvtestrun produces nicer and more readable output

When stdout is a TTY, the results are aligned to the same column and are
proceeded by colorized leaders ("........") to easily find the text
related to the result.

Although this change goes against the basic WvTest principle "Be the
stupidest thing that can possibly work", I find it highly useful.

Previously, the output of

$ ./wvtestrun cat sample-ok sample-error

looked like this:

Testing "all" in cat sample-ok sample-error:
! mytest.t.cc my ok test function: .. 0.000s ok
! mytest.t.cc my error test function: .
! mytest.t.cc:432 thing.works() ok
This is just some crap that I printed while counting to 3.
! mytest.t.cc.433 3 < 4 FAILED
0.000s ok

WvTest: 4 tests, 1 failure, total time 0.001s.

Now, we get this:

Testing "all" in cat sample-ok sample-error:
! mytest.t.cc my ok test function: .. 0.000s ................... ok
! mytest.t.cc my error test function: .
! mytest.t.cc:432 thing.works() ............................. ok
This is just some crap that I printed while counting to 3.
! mytest.t.cc.433 3 < 4 ..................................... FAILED
0.000s ......................................................... ok

WvTest: 4 tests, 1 failure, total time 0.001s.

Extra care was taken to properly align the results with all combinations of
line lengths and terminal widths. For example, below is the output for a narrow
terminal.

Testing "all" in cat sample-ok sample-error:
! mytest.t.cc my ok test function: .. 0.000s .........
........................................ ok
! mytest.t.cc my error test function: .
! mytest.t.cc:432 thing.works() .... ok
This is just some crap that I printed while counting to
3.
! mytest.t.cc.433 3 < 4 ............ FAILED
0.000s ................................ ok

WvTest: 4 tests, 1 failure, total time 0.000s.