lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Any specific advantages over LuaCov?


Tysen Moore <>schreef:

This is a simple Lua code coverage script.  This can be especially useful in Lua since many errors are not found until the code executes.  This implementation was originally written to gather stats in an embedded system so I purposely wrote the code with the smallest number of dependencies and as a single file for simple portability.

You can run this script by adding the necessary function calls to start and stop, OR you can execute lcov and pass in the code under test as an argument.

This script will take the actual execution and determine the overall coverage.  This script will better determine the actual coverage based on what Lua told us. For example, Lua will indicate a "repeat" statement is called by indicating the "until" line that the loop was executed, not the starting "repeat"; multi-line comments/stings are similar; require statements don't show any execution, etc.  This script cleans all this up (and more) to show better and more accurate coverage stats while retaining the actual execution as tracked from Lua.

I've tested the code with some of real world code as well as a sample test file and had good results.  However I suspect there is crazier syntax that is untested that will need special handling.  Also, I've currently only tested this under 5.1.4--as this is my current target for our embedded applications.

Any suggestions/comment/etc are welcome.

Code / example / docs: