lunarmodules / luacov

LuaCov is a simple coverage analyzer for Lua code.
http://lunarmodules.github.io/luacov/
MIT License
300 stars 68 forks source link

Don't require source to begin with @ in runner.lua #15

Closed britzl closed 10 years ago

britzl commented 10 years ago

On line 49 of runner.lua (https://github.com/keplerproject/luacov/blob/master/src/luacov/runner.lua#L49) there's a check to make sure that debug.getinfo().source begins with an '@' with the comment saying "ignore Lua code loaded from raw strings". I'm running unit tests/integration tests from within a game engine with Lua scripting and none of the source files begin with '@' in this case. Is there some way this requirement could be turned into an option, or is it needed at all?

I do of course have several workarounds: forking and removing the requirement, modifying a local copy of the code, patching debug.getinfo() to always append an '@' but I'd like to discuss other options as well.

hishamhm commented 10 years ago

Does your code work simply removing that test? We could make that into a configurable option.

britzl commented 10 years ago

Yes, the current version of LuaCov runs perfectly if I remove the conditional. It collects coverage stats as expected. A configurable option would be great!

hishamhm commented 10 years ago

I added an entry to the config file format that does what you need! See luacov/defaults.lua and README.md for more info on the config file.