lua-users home
lua-l archive

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


I'm trying to use a line hook and the "activelines" table returned by "debug.getinfo( f, 'L' )" to calculate coverage of functions in unit tests. This table contains most (or maybe all) of the source lines which contain just the keyword 'end'. This implies that there are some VM instructions associated with the end keyword (I know almost nothing about the VM), which is OK. The problem is that whenever there's a 'return' or 'break' statement before 'end', the 'end'-code (or maybe just the line hook) never gets called, which results in many 'end'-only lines falsely appearing as "non-covered".
I can see two workarounds - one is to modify the source code so that any 'end's after return/break are placed on the same line as the return/break; the other is to have the unit testing framework scan the source files and ignore the non-covered lines which contain 'end' only. I don't like both of them (especially the first). Is there something better that can be done to avoid this problem?