I’ll personally award three kudos points to anyone who implements a patch
to apply some level of highlighting to the console output of a unit test.
It should try to load the ‘text/highlight’ package available on the RAA
(or some other package if appropriate) and continue gracefully without
highlighting if that library is not available.
Any takers?
Gavin
Gavin Sinclair wrote:
I’ll personally award three kudos points to anyone who implements a patch
to apply some level of highlighting to the console output of a unit test.
It should try to load the ‘text/highlight’ package available on the RAA
(or some other package if appropriate) and continue gracefully without
highlighting if that library is not available.
I have spend some time this morning… attempting to replace the $stdout
and $stderr filedescriptors with a pipe. Whenever something is outputted
to stdout it could be colored green, and red output if stderr.
I have done it before… but no success today.
If you read this, then it means I never made it.
Earlier I have used fork, where the childprocess writes into one end of
the pipe, and where the parentprocess reads from the other end.
However there is no forking here, so what matters is correct replacement
of filedescriptor#1… however its behaving weird.
expand -t2 col.rb
BLACK = “\x1b[30m”
RED = “\x1b[31m”
GREEN = “\x1b[32m”
#puts “#{RED}hello#{BLACK} world”
def capture(&block)
x = $stdout.dup
p x, x.isatty
p $stdout, $stdout.isatty
r1, w1 = IO.pipe # stdout
fdes = [r1]
thread = Thread.new do
loop do
res = select(fdes, nil, nil, 0.1)[0]
if res.include?(r1)
unless r1.eof
x.print “#{GREEN} #{r1.read} #{BLACK}”
else
fdes.delete r1
thread.kill if fdes ==
end
end
end
end
#$stdout.reopen(w1)
$stdout = w1
op = [$stdout.inspect, $stdout.isatty.inspect]
block.call
w1.flush
#w1.close
$stdout.reopen(x)
sleep(0.5) # r1.eof?
thread.kill
r1.close
#$stdout.reopen(x)
#$stdout = STDOUT
puts op.join(“\n”)
end
puts “before”
capture do
puts “stdout”
$stderr.puts “stderr”
puts “stdout”
end
puts “after”
···
–
Simon Strandgaard
“Gavin Sinclair” gsinclair@soyabean.com.au wrote in message news:43526.129.78.64.101.1084831986.squirrel@webmail.imagineis.com…
I’ll personally award three kudos points to anyone who implements a patch
to apply some level of highlighting to the console output of a unit test.
It should try to load the ‘text/highlight’ package available on the RAA
(or some other package if appropriate) and continue gracefully without
highlighting if that library is not available.
Any takers?
Gavin
I can have a look at it, it should be easy to do. What output do you
want to be highlighted, and in which colors ?
Denis
So here is a patch to apply to test/unit
It is really experimental and needs more work, but it is already functionnal.
http://flwrpwr.free.fr/Ruby/testunit_hl_console.diff
apply with:
cd ruby-1.8.1/lib
patch -p0 < path_to/testunit_hl_console.diff
and you will have to reinstall test/unit.
Hope it will help.
Denis
In most cases, the stuff I really want to see stand out are error
messages and the backtrace, so I can see where to go looking.
If, in the backtrace, you can identify the line in the unit test
file and highlight that especially, that would be fantastic.
As for colour choice: I use a black background, and “bold” colours
tend to display much better. So yellow, cyan, and green are probably
the three to use.
Cheers,
Gavin
···
On Tuesday, May 18, 2004, 8:28:49 PM, denis wrote:
“Gavin Sinclair” gsinclair@soyabean.com.au wrote in message
news:43526.129.78.64.101.1084831986.squirrel@webmail.imagineis.com…
I’ll personally award three kudos points to anyone who implements a patch
to apply some level of highlighting to the console output of a unit test.
It should try to load the ‘text/highlight’ package available on the RAA
(or some other package if appropriate) and continue gracefully without
highlighting if that library is not available.
Any takers?
Gavin
I can have a look at it, it should be easy to do. What output do you
want to be highlighted, and in which colors ?
But test/unit ships with 1.8.1. How does one reinstall just test/unit?
···
On Wednesday, 19 May 2004 at 0:33:48 +0900, denis wrote:
So here is a patch to apply to test/unit
It is really experimental and needs more work, but it is already functionnal.
and you will have to reinstall test/unit.
–
Jim Freeze
Welcome thy neighbor into thy fallout shelter. He’ll come in handy if
you run out of food.
– Dean McLaughlin.