Builtin Library
README.md
luau_coverage Module
Public Luau surface over the __luau_coverage Internal FFI namespace
— LCOV-style coverage dump for Luau scripts.
Purpose
Wrap the raw __luau_coverage.* FFI namespace in a typed Luau table
that gets auto-injected as _G.luau_coverage via the prelude. Only
populated when the VM was constructed with coverage enabled
(ZERO_LUAU_COVERAGE=1 or 2 at startup); otherwise the module
returns a small stub so probing scripts don't crash on non-coverage
builds.
Captures are written as LCOV with a sibling luau_sources/ directory
containing source bytes and a manifest.json mapping chunk names to
files — that's what the proxy /ui/coverage page renders.
Usage
if luau_coverage.level() > 0 then
-- Exercise a scenario in isolation
luau_coverage.reset()
runScenario()
local r = luau_coverage.dump_lcov("/tmp/scenario.lcov")
print(r.records, "records,", r.bytes, "bytes,", r.sources_written, "sources")
end
Exports
luau_coverage.dump_lcov(path) -> DumpResult— render LCOV + write.luau_coverage.level() -> number— compile-time coverage level.luau_coverage.reset() -> boolean— drop accumulated coverage.