diff options
author | mpeterv <mpeterval@gmail.com> | 2016-04-17 15:29:22 +0300 |
---|---|---|
committer | mpeterv <mpeterval@gmail.com> | 2016-04-17 15:29:35 +0300 |
commit | 5a2b939cc5ccf284b67995980a4d66eace2977e9 (patch) | |
tree | c99c19a029010befe24710accbd390e3dcb59960 | |
parent | 933c68092a8e9667dbd4bef9fdf4bb2d325ccb12 (diff) | |
download | luacov-5a2b939cc5ccf284b67995980a4d66eace2977e9.tar.gz |
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.
-rw-r--r-- | src/luacov/runner.lua | 2 | ||||
-rw-r--r-- | src/luacov/tick.lua | 4 | ||||
-rw-r--r-- | 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() |