From: mrp@... Date: 2002-05-03T18:52:37+09:00 Subject: set_trace_func and code coverage ruby 1.6.6 #!/usr/local/bin/ruby -w $lines = [] set_trace_func( proc {|eventname, filename, lineno, objid, binding, classname| $lines << lineno if ( eventname == "line") }) at_exit { puts $lines.sort.uniq } ['foo','bar','baz'].each{|w| puts w # line 9 } # line 10 ===== produces: $ ./cover.rb foo bar baz 6 8 9 $ and if |w| was on it's own line, that's not 'executed' either. from a parsing point of view i can see that line 10 isn't _really_ executable code, but from trying to use this as a code coverage tool, this is a bit of a pain, especially with lines containing many delimiters. my question's are: should lines containing just delimeters be included with the output shown above, or is thinking about code-coverage a bit out of date with dynamic languages? or is there a coverage tool for ruby out there already? (i couldn't find it!) thanks, martin.