Skip to content

Commit a48034a

Browse files
nshylocker
authored andcommitted
test: fix luaunit/assertions_error_test for Tarantool 3.2 and newer
With Tarantool 3.2 and newer the test fails with: ``` ...luatest/test/luaunit/assertions_error_test.lua:244: Unexpected error trace, expected: {file = "/home/runner/work/luatest/luatest/luatest/assertions.lua", line = 102}, actual: { file = "...k/luatest/luatest/test/luaunit/assertions_error_test.lua", line = 236, } ``` On older Tarantool versions the error trace isn't checked because `tarantool._internal.trace_check_is_required` isn't defined there. Tarantool 3.2 is the first version that defines this internal function. Since `error.raise` used by the test resides in 'builtin/error.lua', stack trace checking is enabled for this function. The problem is `error.raise()` does not change the original error trace while `t.assert_error_covers()` expects the trace to point to the place where `error.raise()` was invoked. Let's use `box.error()` instead so the new error has the expected trace. Also change `box.error.ILLEGAL_PARAMS` to `box.error.UNSUPPORTED` for the check to pass because in Tarantool 3.2 the former was changed to `{type = 'IllegalParams'}`.
1 parent e251105 commit a48034a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

test/luaunit/assertions_error_test.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,13 @@ function g.test_assert_errorCovers()
235235
t.assert_error_covers({type = 'ClientError', code = 0}, box.error, 0)
236236
local err = box.error.new(box.error.UNKNOWN)
237237
if err.set_prev ~= nil then
238-
err:set_prev(box.error.new(box.error.ILLEGAL_PARAMS, 'foo'))
238+
err:set_prev(box.error.new(box.error.UNSUPPORTED, 'foo', 'bar'))
239239
expected = {
240240
type = 'ClientError',
241241
code = box.error.UNKNOWN,
242-
prev = {code = box.error.ILLEGAL_PARAMS}
242+
prev = {type = 'ClientError', code = box.error.UNSUPPORTED}
243243
}
244-
t.assert_error_covers(expected, err.raise, err)
244+
t.assert_error_covers(expected, box.error, err)
245245
end
246246

247247
-- test assert failure due to unexpected error trace

0 commit comments

Comments
 (0)