LuaCov-Skynet is a modified version of LuaCov designed specifically for the Skynet framework.
The original LuaCov has data conflicts in Skynet's multi-actor environment. This version solves the problem by creating separate files for each actor.
git clone https://github.com/rakuv3r/luacov-skynet.git
cd luacov-skynet
gcc -shared -fPIC -o src/fileutil.so src/fileutil.cFor better performance, install the C extension: cluacov-skynet
luacov-skynet will automatically detect and use the high-performance version if available.
require("luacov.tick")# Start coverage collection
touch luacov.report
# Run your skynet program
./your_program
# Generate report
luacov -r lcov -s luacov.stats.out.actor.1
# For multiple actors, merge results
lcov -a luacov.stats.out.actor.1 -a luacov.stats.out.actor.2 -o coverage.lcov- Each actor creates separate
.actor.{id}files to avoid data conflicts - Control coverage collection through file creation/deletion
- Use C extension module for better file detection performance
- Support LCOV format output
Create .luacov file in project root:
return {
statsfile = "luacov.stats.out",
reportfile = "luacov.report.out",
include = {"^src/"},
exclude = {"test/"}
}| Action | Method |
|---|---|
| Start collection | touch luacov.report |
| Reset data | touch luacov.reset |
| Stop collection | Remove luacov.doing file |
Failed to compile fileutil.so
- Make sure gcc compiler is installed
- Check write permissions
No coverage data generated
- Confirm
luacov.doingfile exists - Check if
require("luacov.tick")is called correctly
Multiple actor data problems
- Check if multiple
.actor.{id}files are generated - Use
lcovcommand to merge files correctly
When the program runs:
- Store coverage data in global variables
- Start a 1-second timer to check control files
- Save or reset data based on file existence
- Each actor writes to separate stats files
File monitoring interval is 1 second. We recommend at least 2 seconds between control file operations.
