This post originated from an RSS feed registered with Ruby Buzz
by Ryan Davis.
Original Post: Heckle: Another Rubyconf Hack
Feed Title: Polishing Ruby
Feed URL: http://blog.zenspider.com/index.rdf
Feed Description: Musings on Ruby and the Ruby Community...
Jester is a java test tool that finds code that is not covered by tests. It does this via bytecode mutation to modify code paths of the class under test. First it runs your tests and they should all pass (ass usual). Then it will modify conditionals for branching, change literals, and generally wreck havok, making one change at a time. By rerunning the tests per change, if they don't fail, then you've missed a test case. All in all this is pretty damn cool.
It turns out that getting a simple prototype up and running with 'if' node flipping takes about 100 lines of code. The meat of it is:
def process_defn(exp)
self.method = exp.shift
result = [:defn, method]
result << process(exp.shift) until exp.empty?
heckle(result) if should_heckle?
return result
end
def process_if(exp)
cond = process(exp.shift)
t = process(exp.shift)
f = process(exp.shift)
if should_heckle? then
[:if, cond, f, t]
else
[:if, cond, t, f]
end
end
I've named it heckle and released it on rubyforge and Kevin Clark went insane last night and poured through it, ruby2ruby, and ParseTree to dig deeper. I haven't seen him this morning yet so I don't know if he's succeeded extending it yet. We'll see. There will be a more official release soon.