-
Notifications
You must be signed in to change notification settings - Fork 0
/
luatest.patch
65 lines (63 loc) · 2.65 KB
/
luatest.patch
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
diff --git a/luatest/assertions.lua b/luatest/assertions.lua
index 6902133..cbe8da3 100644
--- a/luatest/assertions.lua
+++ b/luatest/assertions.lua
@@ -46,6 +46,31 @@ if math.abs(1.1 - 1 - 0.1) > M.EPS then
M.EPS = 2^-23 -- = machine epsilon for "float", ~1.19E-07
end
+local function check_luatest_auto(actualMsg, expectedMsg, depth)
+ if string.endswith(expectedMsg, '"auto"') then
+ local fio = require('fio')
+ local flags = {'O_RDWR', 'O_APPEND', 'O_CREAT', 'O_TRUNC'}
+ local mode = tonumber('644',8)
+ local tmpstr = actualMsg
+ for k=1,8 do
+ tmpstr = string.gsub(tmpstr, "\n ", "\n")
+ tmpstr = string.gsub(tmpstr, "\n\t", "\n")
+ end
+ tmpstr = string.gsub(tmpstr, "\n", " ")
+ tmpstr = string.gsub(tmpstr, "}, }", "} }")
+ tmpstr = string.strip(tmpstr)
+ if tmpstr:startswith("[") and tmpstr:endswith("]") then
+ tmpstr = "{" .. tmpstr:sub(2, #tmpstr - 1) .. "}"
+ end
+
+ local f = fio.open('/tmp/luatest_auto.txt', flags, mode)
+ local info = debug.getinfo(depth+3)
+ f:write(info.source .. ':' .. tostring(info.currentline) .. '\n')
+ f:write(tmpstr)
+ f:close()
+ end
+end
+
local function failure(msg, extra_msg, level)
-- raise an error indicating a test failure
-- for error() compatibility we adjust "level" here (by +1), to report the
@@ -178,6 +203,8 @@ end
-- @bool[opt] deep_analysis print diff.
function M.assert_equals(actual, expected, message, deep_analysis)
if not comparator.equals(actual, expected) then
+ local strExpected, strActual = prettystr_pairs(expected, actual)
+ check_luatest_auto(strActual, strExpected, 0)
failure(M.private.error_msg_equality(actual, expected, deep_analysis), message, 2)
end
end
@@ -497,6 +524,7 @@ local function _assert_error_msg_equals(stripFileAndLine, expectedMsg, func, ...
if differ then
error_msg, expectedMsg = prettystr_pairs(error_msg, expectedMsg)
+ check_luatest_auto(error_msg, expectedMsg, 1)
fail_fmt(3, nil, 'Error message expected: %s\nError message received: %s\n',
expectedMsg, error_msg)
end
diff --git a/luatest/helpers.lua b/luatest/helpers.lua
index ea9bfc0..d72c5fc 100644
--- a/luatest/helpers.lua
+++ b/luatest/helpers.lua
@@ -60,6 +60,7 @@ helpers.RETRYING_DELAY = 0.1
function helpers.retrying(config, fn, ...)
local timeout = config.timeout or helpers.RETRYING_TIMEOUT
+ timeout = timeout / 5
local delay = config.delay or helpers.RETRYING_DELAY
local started_at = clock.time()
while true do
local ok, result = pcall(fn, ...)