From 5a2b939cc5ccf284b67995980a4d66eace2977e9 Mon Sep 17 00:00:00 2001 From: mpeterv Date: Sun, 17 Apr 2016 15:29:22 +0300 Subject: Fix luacov.tick luacov.runner.init used package.loaded["luacov.tick"] to determine whether it should save stats from time to time. luacov.tick module used to set that field implicitly because it called module(). In @8872071 (Oct 2012) module() call was removed, leaving luacov.tick broken. Incidentally that always enabled on-exit gc hooks, so the problem was not visible unless Lua somehow exited without calling them. The fix is to use runner.tick field instead of package.loaded for storing the flag. --- src/luacov/runner.lua | 2 +- src/luacov/tick.lua | 4 +++- tests/nested/subdir/script.lua | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/luacov/runner.lua b/src/luacov/runner.lua index 48d7ba7..23d96f0 100644 --- a/src/luacov/runner.lua +++ b/src/luacov/runner.lua @@ -476,7 +476,7 @@ end function runner.init(configuration) runner.configuration = runner.load_config(configuration) stats.statsfile = runner.configuration.statsfile - tick = package.loaded["luacov.tick"] + tick = runner.tick runner.resume() -- metatable trick on filehandle won't work if Lua exits through diff --git a/src/luacov/tick.lua b/src/luacov/tick.lua index dbb43c6..fdf2b2d 100644 --- a/src/luacov/tick.lua +++ b/src/luacov/tick.lua @@ -5,5 +5,7 @@ -- @class module -- @name luacov.tick -- @see luacov.defaults.savestepsize -require("luacov") +local runner = require("luacov.runner") +runner.tick = true +runner.init() return {} diff --git a/tests/nested/subdir/script.lua b/tests/nested/subdir/script.lua index ef278a2..f69da5c 100644 --- a/tests/nested/subdir/script.lua +++ b/tests/nested/subdir/script.lua @@ -2,4 +2,4 @@ local testlib = require "testlib" testlib.f1() testlib.f2() testlib.f2() -os.exit() +osexit() -- cgit v1.2.1