Skip to content

Commit 02f4a85

Browse files
authored
Fix test for new Tarantool version and debug build (#42)
* fix assign to undeclared variable error Tarantool in debug build has strict mode enabled by default. As result before this patch we faced an error "assign to undeclared variable". * fix error messages for new Tarantool versions - netbox timeout error was changed (tarantool/tarantool#6538) - error on connection refused was extended
1 parent 13434db commit 02f4a85

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

test/unit/errors_test.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ local my_error = errors.new_class('My error')
99
local current_file = debug.getinfo(1, 'S').short_src
1010

1111
g.before_all = function()
12-
_G.my_error = my_error
12+
rawset(_G, 'my_error', my_error)
1313
end
1414

1515
function g.test_error_new()

test/unit/netbox_test.lua

+17-13
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,16 @@ g.before_all = function()
3535
'universe', nil, {if_not_exists = true}
3636
)
3737

38-
_G.my_error = my_error
39-
_G.remote_4args_fn = remote_4args_fn
38+
rawset(_G, 'my_error', my_error)
39+
rawset(_G, 'remote_4args_fn', remote_4args_fn)
4040
end
4141

4242
g.before_each(function()
4343
g.conn = netbox.connect('127.0.0.1:3301')
44+
local ok, err = pcall(g.conn.call, g.conn, 'table.insert', {{}, {}}, {timeout = 0})
45+
t.assert_not(ok)
46+
g.timeout_error = tostring(err)
47+
t.assert(g.timeout_error == 'Timeout exceeded' or g.timeout_error == 'timed out')
4448
end)
4549

4650
function g.test_errors_netbox_eval()
@@ -109,7 +113,7 @@ function g.test_errors_netbox_eval()
109113

110114

111115
local _l1, remote_fn = h.get_line(), function() return nil, my_error:new('Fuschia Platinum') end
112-
_G.remote_fn = remote_fn
116+
rawset(_G, 'remote_fn', remote_fn)
113117

114118
local _l2, _, err = h.get_line(), errors.netbox_eval(g.conn, 'return remote_fn()')
115119
h.check_error(err, {
@@ -159,8 +163,8 @@ function g.test_errors_netbox_eval()
159163
local _l, _, err = h.get_line(), errors.netbox_eval(conn, 'return true')
160164
h.check_error(err, {
161165
file = 'builtin/box/net_box.lua',
162-
err = '"127.0.0.1:9": Connection refused',
163-
str = '^NetboxEvalError: "127.0.0.1:9": Connection refused\n' ..
166+
err = '"127.0.0.1:9": ' .. conn.error,
167+
str = '^NetboxEvalError: "127.0.0.1:9": ' .. conn.error .. '\n' ..
164168
'stack traceback:\n' ..
165169
'.+\n' ..
166170
('\t%s:%d: .*$'):format(current_file, _l)
@@ -179,7 +183,7 @@ function g.test_errors_netbox_call()
179183
}, 'netbox_call(fn_undefined)')
180184

181185
local _l1, remote_fn = h.get_line(), function() return nil, my_error:new('Yellow Iron') end
182-
_G.remote_fn = remote_fn
186+
rawset(_G, 'remote_fn', remote_fn)
183187

184188
local _l2, _, err = h.get_line(), errors.netbox_call(g.conn, 'remote_fn')
185189
h.check_error(err, {
@@ -220,16 +224,16 @@ end
220224
function g.test_errors_netbox_wait_async()
221225
-- future returns error
222226
local long_call = function() fiber.sleep(10) return 5 end
223-
_G.long_call = long_call
227+
rawset(_G, 'long_call', long_call)
224228

225229
local csw1 = h.fiber_csw()
226230

227231
local future_call = errors.netbox_call(g.conn, '_G.long_call', nil, {is_async = true})
228232
local _l, _, err = h.get_line(), errors.netbox_wait_async(future_call, 0)
229233
h.check_error(err, {
230234
file = debug.getinfo(errors.netbox_wait_async).source:gsub('@', ''),
231-
err = '"127.0.0.1:3301": Timeout exceeded',
232-
str = '^NetboxCallError: "127.0.0.1:3301": Timeout exceeded\n' ..
235+
err = '"127.0.0.1:3301": ' .. g.timeout_error,
236+
str = '^NetboxCallError: "127.0.0.1:3301": ' .. g.timeout_error .. '\n' ..
233237
'stack traceback:\n' ..
234238
'.+\n' ..
235239
('\t%s:%d: .*$'):format(current_file, _l)
@@ -239,8 +243,8 @@ function g.test_errors_netbox_wait_async()
239243
local _l, _, err = h.get_line(), errors.netbox_wait_async(future_eval, 0)
240244
h.check_error(err, {
241245
file = debug.getinfo(errors.netbox_wait_async).source:gsub('@', ''),
242-
err = '"127.0.0.1:3301": Timeout exceeded',
243-
str = '^NetboxEvalError: "127.0.0.1:3301": Timeout exceeded\n' ..
246+
err = '"127.0.0.1:3301": ' .. g.timeout_error,
247+
str = '^NetboxEvalError: "127.0.0.1:3301": '.. g.timeout_error .. '\n' ..
244248
'stack traceback:\n' ..
245249
'.+\n' ..
246250
('\t%s:%d: .*$'):format(current_file, _l)
@@ -421,7 +425,7 @@ function g.test_errors_wrap_remote()
421425
}, 'wrap conn:eval("return nil, e:new()")')
422426

423427
local _l1, remote_fn = h.get_line(), function() return nil, my_error:new('Fuschia Platinum') end
424-
_G.remote_fn = remote_fn
428+
rawset(_G, 'remote_fn', remote_fn)
425429

426430
local _l2, _, err = h.get_line(), errors.wrap(g.conn:eval('return remote_fn()'))
427431
h.check_error(err, {
@@ -438,7 +442,7 @@ function g.test_errors_wrap_remote()
438442
}, 'wrap conn:eval("return remote_fn()")')
439443

440444
local _l1, remote_fn = h.get_line(), function() return nil, my_error:new('Yellow Iron') end
441-
_G.remote_fn = remote_fn
445+
rawset(_G, 'remote_fn', remote_fn)
442446

443447
local _l2, _, err = h.get_line(), errors.wrap(g.conn:call('remote_fn'))
444448
h.check_error(err, {

0 commit comments

Comments
 (0)