summaryrefslogtreecommitdiff
path: root/tests/nested/test.lua
blob: 4a7073d0d533c699563bbed6452e0b4deb216040 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
local testlib = require "testlib"
local luacov = require "luacov.runner"

testlib.f1()

local dir_sep = package.config:sub(1, 1)
local lua = arg[-4] or "lua"
local slash = lua:find(dir_sep)

if slash and slash ~= 1 then
   lua = ".." .. dir_sep .. lua
end

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)
end

test(true)
test(false)

testlib.f2()