Page MenuHomePhabricator

Allowlist `debug.sethook` in the Lua engine, for code coverage tools
Open, Needs TriagePublic

Description

Is it possible for debug.sethook to be made available in the Lua engine? Custom hooks would be highly useful for computing code coverage in tests. There's quite a few test engines for wiki modules, but only a couple modules mention anything similar to statement code coverage.

Event Timeline

Aklapper renamed this task from Sethook for code coverage tools? to Allowlist `debug.sethook` in the Lua engine, for code coverage tools.Apr 17 2020, 9:41 AM

Perhaps this could be implemented securely in C via lua_sethook and lua_getinfo, then exposed as a Lua global. Events could be exposed by a custom mw.hook interface like the JS one.

The event callback could accept source/function name and optional line number (for new line event) as arguments.