mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
wrap computation intensive functions in hook free env when makeing coverage test
so that Travis CI job won't fail because of timeout.
This commit is contained in:
4
.luacov
4
.luacov
@@ -2,6 +2,10 @@
|
||||
-- project folder as '.luacov' for project specific configuration
|
||||
-- @class module
|
||||
-- @name luacov.defaults
|
||||
|
||||
-- global flag to indicate coverage test
|
||||
LUACOV = true
|
||||
|
||||
return {
|
||||
|
||||
-- default filename to load for config options if not provided
|
||||
|
||||
@@ -21,3 +21,25 @@ Input.dummy = true
|
||||
-- turn on debug
|
||||
local DEBUG = require("dbg")
|
||||
--DEBUG:turnOn()
|
||||
|
||||
-- remove debug hooks in wrapped function for better luacov performance
|
||||
if LUACOV then
|
||||
local function hook_free_call(callback)
|
||||
local hook, mask, count = debug.gethook()
|
||||
debug.sethook()
|
||||
local res = callback()
|
||||
debug.sethook(hook, mask)
|
||||
return res
|
||||
end
|
||||
|
||||
local UIManager = require("ui/uimanager")
|
||||
local uimanager_run = UIManager.run
|
||||
function UIManager:run()
|
||||
hook_free_call(function() return uimanager_run(UIManager) end)
|
||||
end
|
||||
|
||||
local screen_shot = Screen.shot
|
||||
function Screen:shot(filename)
|
||||
hook_free_call(function() return screen_shot(Screen, filename) end)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user