summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Melnichenko <mpeterval@gmail.com>2016-06-28 23:53:32 +0300
committerPeter Melnichenko <mpeterval@gmail.com>2016-06-28 23:53:32 +0300
commitc65e8084d2543b82c6bd2f5613b2fcb48a431511 (patch)
tree82de263b8967c509fc62307876b0d8bebc6a05f9
parent929a6d310c03d1562b153c46ee201a54d02af964 (diff)
downloadluacov-c65e8084d2543b82c6bd2f5613b2fcb48a431511.tar.gz
Add a test for `tick` option in config
-rw-r--r--tests/nested/expected.out20
-rw-r--r--tests/nested/subdir/.luacov4
-rw-r--r--tests/nested/subdir/tick.luacov5
-rw-r--r--tests/nested/test.lua29
4 files changed, 37 insertions, 21 deletions
diff --git a/tests/nested/expected.out b/tests/nested/expected.out
index fb5891e..7b73c26 100644
--- a/tests/nested/expected.out
+++ b/tests/nested/expected.out
@@ -1,22 +1,22 @@
==============================================================================
testlib.lua
==============================================================================
- 2 local a = 1
- 2 local b = 2
+ 3 local a = 1
+ 3 local b = 2
- 2 local lib = {}
+ 3 local lib = {}
- 2 function lib.f1()
- 2 local c = 3
- 2 return 4
+ 3 function lib.f1()
+ 3 local c = 3
+ 3 return 4
end
- 2 function lib.f2()
- 3 local d = 5
- 3 return 6
+ 3 function lib.f2()
+ 5 local d = 5
+ 5 return 6
end
- 2 return lib
+ 3 return lib
==============================================================================
Summary
diff --git a/tests/nested/subdir/.luacov b/tests/nested/subdir/.luacov
new file mode 100644
index 0000000..b4dc207
--- /dev/null
+++ b/tests/nested/subdir/.luacov
@@ -0,0 +1,4 @@
+return {
+ savestepsize = 1,
+ statsfile = "../luacov.stats.out"
+}
diff --git a/tests/nested/subdir/tick.luacov b/tests/nested/subdir/tick.luacov
new file mode 100644
index 0000000..92aed79
--- /dev/null
+++ b/tests/nested/subdir/tick.luacov
@@ -0,0 +1,5 @@
+return {
+ savestepsize = 1,
+ statsfile = "../luacov.stats.out",
+ tick = true
+}
diff --git a/tests/nested/test.lua b/tests/nested/test.lua
index f312d43..4a7073d 100644
--- a/tests/nested/test.lua
+++ b/tests/nested/test.lua
@@ -4,21 +4,28 @@ local luacov = require "luacov.runner"
testlib.f1()
local dir_sep = package.config:sub(1, 1)
-local cmd = arg[-4] or "lua"
-local slash = cmd:find(dir_sep)
+local lua = arg[-4] or "lua"
+local slash = lua:find(dir_sep)
if slash and slash ~= 1 then
- cmd = ".." .. dir_sep .. cmd
+ lua = ".." .. dir_sep .. lua
end
-cmd = ("%q"):format(cmd) .. ' -e "package.path=[[../?.lua;../../../src/?.lua;]]..package.path"'
-cmd = cmd .. ' -e "osexit = os.exit"'
-cmd = cmd .. ' -e "require([[luacov.runner]]).load_config({statsfile = [[../luacov.stats.out]], savestepsize = 1})"'
-cmd = cmd .. " -l luacov.tick"
-cmd = cmd .. ' -e "dofile([[script.lua]])"'
-cmd = cmd:gsub("/", dir_sep)
+local function test(tick_as_module)
+ local config = tick_as_module and ".luacov" or "tick.luacov"
+ local mod = tick_as_module and "luacov.tick" or "luacov"
+ local cmd = ("%q"):format(lua) .. ' -e "package.path=[[../?.lua;../../../src/?.lua;]]..package.path"'
+ cmd = cmd .. ' -e "osexit = os.exit"'
+ cmd = cmd .. ' -e "require([[luacov.runner]]).load_config([[' .. config .. ']])"'
+ cmd = cmd .. " -l " .. mod
+ cmd = cmd .. ' -e "dofile([[script.lua]])"'
+ cmd = cmd:gsub("/", dir_sep)
-local ok = os.execute("cd subdir && " .. cmd)
-assert(ok == 0 or ok == true)
+ local ok = os.execute("cd subdir && " .. cmd)
+ assert(ok == 0 or ok == true)
+end
+
+test(true)
+test(false)
testlib.f2()