|
On 8/10/2009, at 11:24 AM, Robert G. Jakabosky wrote:
Put this in "luacov_on_exit.lua": --- start require('luacov') local luacovlock = os.tmpname() function on_exit() os.remove(luacovlock) stats.save_stats(data, statsfile) stats.stop_stats(statsfile) end on_exit_trick = io.open(luacovlock, "w") debug.setmetatable(on_exit_trick, { __gc = on_exit } ) local exit=os.exit os.exit = function(...) on_exit() exit(...) end --- end Then run your program with: lua -lluacov_on_exit script.lua
Yeah, that's right. For some reason I was stuck thinking I didn't want to change lua, but I've already made lots of changes to luacov. Thanks for pointing that out.