views:

58

answers:

2

I've been using the built-in OSX 'say' command to signal the end of long running tests. It's easy and convenient.

I'd like to make it speak the last line of the results which says "6 tests, 18 assertions, 0 failures, 0 errors" but still keep the ongoing output. Any ideas how to do this?

I've tried:

ruby overlay_test.rb | tail -n 1 | say

But that doesn't output the tests results as they happen.

Bonus points for making it say just the last two parts of the line "0 failures, 0 errors".

+2  A: 

You can use tee to direct output to multiple files/processes (here, say and STDOUT):

ruby overlay_test.rb | tail -n 1 | tee >(say)

For the bonus, get rid of what you don't want with sed:

ruby overlay_test.rb | tail -n 1 | sed -e 's/.*assertions, //' | tee >(say)
Alex Reisner
+1  A: 

Thanks!

tee is just what I needed. Though the winning command turned out to be:

ruby overlay_test.rb | tee >(tail -n 1 |sed -e 's/.*assertions, //' |  say)

since I wanted to see more than just the last line of the test when it runs.

Matt