File: helper.lua

package info (click to toggle)
lua-http 0.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 1,100 kB
  • sloc: makefile: 60; sh: 16
file content (31 lines) | stat: -rw-r--r-- 862 bytes parent folder | download | duplicates (2)
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
TEST_TIMEOUT = 10

function assert_loop(cq, timeout)
	local ok, err, _, thd = cq:loop(timeout)
	if not ok then
		if thd then
			err = debug.traceback(thd, err)
		end
		error(err, 2)
	end
end

-- Solves https://github.com/keplerproject/luacov/issues/38
local cqueues = require "cqueues"
local has_luacov, luacov_runner = pcall(require, "luacov.runner")
if has_luacov then
	local wrap; wrap = cqueues.interpose("wrap", function(self, func, ...)
		func = luacov_runner.with_luacov(func)
		return wrap(self, func, ...)
	end)
end

-- Allow tests to pick up configured locale
local locale = os.getenv("LOCALE")
if locale then
	os.setlocale(locale)
	if locale ~= os.setlocale(locale) then
		print("Locale " .. locale .. " is not available.")
		os.exit(1) -- busted doesn't fail if helper script throws errors: https://github.com/Olivine-Labs/busted/issues/549
	end
end