diff --git a/test/app-luatest/fiber_slice_test.lua b/test/app-luatest/fiber_slice_test.lua index b67f83357f44b..77729be6d801e 100644 --- a/test/app-luatest/fiber_slice_test.lua +++ b/test/app-luatest/fiber_slice_test.lua @@ -32,7 +32,7 @@ g.test_fiber_slice = function() overhead = clock.monotonic() - overhead local start_time = clock.monotonic() local _, err = fib:join() - t.assert_equals(tostring(err), "fiber slice is exceeded") + t.assert_equals(err.message, "fiber slice is exceeded") local time_elapsed = clock.monotonic() - start_time - overhead t.assert_almost_equals(time_elapsed, expected_timeout, delta) end diff --git a/test/app-luatest/http_client_test.lua b/test/app-luatest/http_client_test.lua index eb7fd452267fa..cca9eb2afff73 100644 --- a/test/app-luatest/http_client_test.lua +++ b/test/app-luatest/http_client_test.lua @@ -485,7 +485,7 @@ g.test_headers = function(cg) local headers = {[hname] = hvalue} local ok, err = pcall(http.post, http, url, nil, merge(opts, {headers = headers})) - t.assert_equals({ok, tostring(err)}, {false, exp_err}, + t.assert_equals({ok, err.message}, {false, exp_err}, '8193 KiB header: error') end diff --git a/test/app-tap/console.test.lua b/test/app-tap/console.test.lua index 748014ade66f2..5da6c1c4982f9 100755 --- a/test/app-tap/console.test.lua +++ b/test/app-tap/console.test.lua @@ -133,13 +133,13 @@ box.cfg{ -- Connect to iproto console (CALL) client:write(string.format("require('console').connect('/')\n")) -- error: Connection is not established -test:ok(yaml.decode(client:read(EOL))[1].error:find('not established'), +test:ok(yaml.decode(client:read(EOL))[1].error.message:find('not established'), 'remote network error') client:write(string.format("require('console').connect('%s')\n", IPROTO_SOCKET)) -- error: Execute access is denied for user 'guest' to function 'dostring -test:ok(yaml.decode(client:read(EOL))[1].error:find('denied'), +test:ok(yaml.decode(client:read(EOL))[1].error.message:find('denied'), 'remote access denied') -- create user @@ -147,7 +147,7 @@ box.schema.user.create('test', { password = 'pass' }) client:write(string.format("require('console').connect('test:pass@%s')\n", IPROTO_SOCKET)) -- error: Execute access denied for user 'test' to function 'dostring -test:ok(yaml.decode(client:read(EOL))[1].error:find('denied'), +test:ok(yaml.decode(client:read(EOL))[1].error.message:find('denied'), 'remote access denied') -- Add permissions to execute for `test` diff --git a/test/app-tap/gh-5013-fiber-cancel.test.lua b/test/app-tap/gh-5013-fiber-cancel.test.lua index 7efb6ab5d09b6..231c09d3b7ab8 100755 --- a/test/app-tap/gh-5013-fiber-cancel.test.lua +++ b/test/app-tap/gh-5013-fiber-cancel.test.lua @@ -22,5 +22,5 @@ fiber.yield() print(require('yaml').encode(result)) test:ok(result.res == false, 'expected result is false') -test:ok(tostring(result.err) == 'fiber is cancelled', 'fiber cancellation should be reported') +test:ok(result.err.message == 'fiber is cancelled', 'fiber cancellation should be reported') os.exit(test:check() and 0 or 1) diff --git a/test/app-tap/logger.test.lua b/test/app-tap/logger.test.lua index b5ba28fd1cbd1..714a9ed3f6d81 100755 --- a/test/app-tap/logger.test.lua +++ b/test/app-tap/logger.test.lua @@ -7,7 +7,7 @@ test:plan(119) local function test_invalid_cfg(cfg_method, cfg, name, expected) local _, err = pcall(cfg_method, cfg) - test:ok(tostring(err):find(expected) ~= nil, name) + test:ok(err.message:find(expected) ~= nil, name) end local function test_allowed_types(cfg_method, cfg, name, allowed_types) @@ -205,11 +205,11 @@ test_invalid_cfg(box.cfg, {log_nonblock = true}, -- Test invalid values for setters _, err = pcall(log.log_format, {}) -test:ok(tostring(err):find('should be of type string') ~= nil, +test:ok(err.message:find('should be of type string') ~= nil, "invalid format setter value type") _, err = pcall(log.level, {}) -test:ok(tostring(err):find('should be one of types number, string') ~= nil, +test:ok(err.message:find('should be one of types number, string') ~= nil, "invalid format setter value type") -- Change format and levels. diff --git a/test/app-tap/popen.test.lua b/test/app-tap/popen.test.lua index 3b6d9469f914a..7d657e24eafd5 100755 --- a/test/app-tap/popen.test.lua +++ b/test/app-tap/popen.test.lua @@ -96,7 +96,7 @@ local function test_trivial_echo_output(test) -- Sending a signal using a closed handle gives an error. local exp_err = 'popen: attempt to operate on a closed handle' local ok, err = pcall(ph.signal, ph, popen.signal.SIGTERM) - test:is_deeply({ok, err.type, tostring(err)}, + test:is_deeply({ok, err.type, err.message}, {false, 'IllegalParams', exp_err}, 'signal() on closed handle gives an error') end @@ -247,7 +247,7 @@ local function test_read_timeout(test) -- Read and get a timeout error. local exp_err = 'timed out' local res, err = ph:read({timeout = 0.1}) - test:is_deeply({res, err.type, tostring(err)}, {nil, 'TimedOut', exp_err}, + test:is_deeply({res, err.type, err.message}, {nil, 'TimedOut', exp_err}, 'timeout error') -- Write and read after the timeout error. diff --git a/test/app-tap/uri.test.lua b/test/app-tap/uri.test.lua index 18b37d132337a..7381d7966a3f6 100755 --- a/test/app-tap/uri.test.lua +++ b/test/app-tap/uri.test.lua @@ -90,10 +90,10 @@ local function test_parse(test) expected_errmsg = "Incorrect URI: expected host:service or /unix.socket" u, error = uri.parse("") test:isnil(u, "invalid uri", u) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") u, error = uri.parse("://") test:isnil(u, "invalid uri", u) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") end local function test_format(test) @@ -245,13 +245,13 @@ local function test_parse_uri_query_params(test) expected_errmsg = "Default URI parameters are not allowed for single URI" u, error = uri.parse({ "/tmp/unix.sock", default_params = {q = "v"} }) test:isnil(u, "invalid uri", u) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") -- Multiple URIs is not allowed in `parse` method, -- use `parse_many` instead. expected_errmsg = "Incorrect URI: expected host:service or /unix.socket" u, error = uri.parse({ "/tmp/unix.sock, /tmp/unix.sock"}) test:isnil(u, "invalid uri", u) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") end local function test_parse_uri_set_with_query_params(test) @@ -314,16 +314,16 @@ local function test_parse_uri_set_with_query_params(test) expected_errmsg = "Incorrect URI: expected host:service or /unix.socket" uri_set , error= uri.parse_many("/tmp/unix.sock,,/tmp/unix.sock") test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") uri_set, error = uri.parse_many("/tmp/unix.sock, ,/tmp/unix.sock") test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") uri_set, error = uri.parse_many("/tmp/unix.sock,, /tmp/unix.sock") test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") uri_set, error = uri.parse_many("/tmp/unix.sock ,,/tmp/unix.sock") test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") -- Check that we can't parse string with multiple URIs, @@ -331,7 +331,7 @@ local function test_parse_uri_set_with_query_params(test) expected_errmsg = "Incorrect URI: expected host:service or /unix.socket" local u, error = uri.parse("/tmp/unix.sock, /tmp/unix.sock") test:isnil(u, "invalid uri", u) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") end local function test_parse_uri_set_from_lua_table(test) @@ -575,35 +575,35 @@ local function test_parse_invalid_uri_set_from_lua_table(test) expected_errmsg = "Incorrect type for URI: should be string, number or table" uri_set, error = uri.parse_many(function() end) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") -- Invalid type of value for numerical key expected_errmsg = "Incorrect type for URI: should be string, number or table" uri_set, error = uri.parse_many({"/tmp/unix.sock", function() end}) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") -- Invalid type of value for string keys expected_errmsg = "Invalid URI table: expected " .. "{uri = string, params = table}" .. " or " .. "{string, params = table}" uri_set, error = uri.parse_many({"/tmp/unix.sock", uri = function() end}) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") expected_errmsg = "Incorrect type for URI parameters: should be a table" uri_set, error = uri.parse_many({"/tmp/unix.sock", params = function() end}) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") expected_errmsg = "Incorrect type for URI parameters: should be a table" uri_set, error = uri.parse_many({"/tmp/unix.sock", params = ""}) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") expected_errmsg = "Default URI parameters are not allowed for single URI" uri_set, error = uri.parse_many({"/tmp/unix.sock", default_params = ""}) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") expected_errmsg = "Default URI parameters are not allowed for single URI" uri_set, error = uri.parse_many({"/tmp/unix.sock", default_params = ""}) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") -- Mix "uri=" and numerical keys is banned expected_errmsg = "Invalid URI table: expected " .. @@ -611,13 +611,13 @@ local function test_parse_invalid_uri_set_from_lua_table(test) "{string, params = table}" uri_set, error = uri.parse_many({"/tmp/unix.sock", uri = "/tmp/unix.sock"}) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") -- Several URIs in one string is allowed only when the -- passed as a single string. expected_errmsg = "Incorrect URI: expected host:service or /unix.socket" uri_set, error = uri.parse_many({"/tmp/unix.sock, /tmp/unix.sock"}) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") -- "params" table is allowed only for single URI expected_errmsg = "URI parameters are not allowed for multiple URIs" uri_set, error = uri.parse_many({ @@ -625,7 +625,7 @@ local function test_parse_invalid_uri_set_from_lua_table(test) params = {q1 = "v1"} }) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") -- "params" table is not allowed with nested tables expected_errmsg = "URI parameters are not allowed for multiple URIs" uri_set, error = uri.parse_many({ @@ -633,17 +633,17 @@ local function test_parse_invalid_uri_set_from_lua_table(test) params = {q1 = "v1"} }) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") -- "default_params" table is not allowed in nested URI tables expected_errmsg = "Default URI parameters are not allowed for single URI" uri_set, error = uri.parse_many({{"/tmp/unix.sock", default_params = {}}}) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") -- "default_params" table is not allowed for single URI expected_errmsg = "Default URI parameters are not allowed for single URI" uri_set, error = uri.parse_many({"/tmp/unix.sock", default_params = {}}) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") -- Only one URI is allowed in nested tables expected_errmsg = "Invalid URI table: expected " .. "{uri = string, params = table}" .. " or " .. @@ -653,7 +653,7 @@ local function test_parse_invalid_uri_set_from_lua_table(test) default_params = {q = "v"} }) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") -- Nested URI tables is not allowed in nested tables expected_errmsg = "Invalid URI table: expected ".. "{uri = string, params = table}" .. " or " .. @@ -662,7 +662,7 @@ local function test_parse_invalid_uri_set_from_lua_table(test) {"/tmp/unix.sock", {}} }) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") -- Nested URI table without URI is now allowed expected_errmsg = "Invalid URI table: expected ".. "{uri = string, params = table}" .. " or " .. @@ -672,7 +672,7 @@ local function test_parse_invalid_uri_set_from_lua_table(test) { params = {q = "v"} } }) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") -- Only string key types are allowed in "params" and -- "default_params" table expected_errmsg = "Incorrect type for URI parameter name: " .. @@ -682,14 +682,14 @@ local function test_parse_invalid_uri_set_from_lua_table(test) params = {"v"}, }) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") expected_errmsg = "Default URI parameters are not allowed for single URI" uri_set, error = uri.parse_many({ "/tmp/unix.sock", default_params = {"v"}, }) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") -- Invalid type of values in "params" and -- "default_params" table expected_errmsg = "Incorrect type for URI parameter value: " .. @@ -699,14 +699,14 @@ local function test_parse_invalid_uri_set_from_lua_table(test) params = {q = function() end}, }) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") expected_errmsg = "Default URI parameters are not allowed for single URI" uri_set, error = uri.parse_many({ "/tmp/unix.sock", default_params = {q = function() end}, }) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") expected_errmsg = "Incorrect type for URI parameter value: ".. "should be string or number" uri_set, error = uri.parse_many({ @@ -714,14 +714,14 @@ local function test_parse_invalid_uri_set_from_lua_table(test) params = {q = {function() end}}, }) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") expected_errmsg = "Default URI parameters are not allowed for single URI" uri_set, error = uri.parse_many({ "/tmp/unix.sock", default_params = {q = {function() end}}, }) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") -- Invalid uri string in URIs table expected_errmsg = "Incorrect URI: expected host:service or /unix.socket" uri_set, error = uri.parse_many({ @@ -729,7 +729,7 @@ local function test_parse_invalid_uri_set_from_lua_table(test) "://" }) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") -- Invalid uri in nested URI table expected_errmsg = "Incorrect URI: expected host:service or /unix.socket" uri_set, error = uri.parse_many({ @@ -737,7 +737,7 @@ local function test_parse_invalid_uri_set_from_lua_table(test) {"://"} }) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") -- Same as previous but with "uri=" syntax expected_errmsg = "Incorrect URI: expected host:service or /unix.socket" uri_set, error = uri.parse_many({ @@ -745,7 +745,7 @@ local function test_parse_invalid_uri_set_from_lua_table(test) {uri = "://"} }) test:isnil(uri_set, "invalid uri", uri_set) - test:is(tostring(error), expected_errmsg, "error message") + test:is(error.message, expected_errmsg, "error message") end local test = tap.test("uri") diff --git a/test/box-luatest/gh_6085_limit_iteration_in_space_test.lua b/test/box-luatest/gh_6085_limit_iteration_in_space_test.lua index 38e2fa45dc3d6..d6d0ef6d907e1 100644 --- a/test/box-luatest/gh_6085_limit_iteration_in_space_test.lua +++ b/test/box-luatest/gh_6085_limit_iteration_in_space_test.lua @@ -33,7 +33,7 @@ g.test_limit_iteration = function() local fib = fiber.new(fiber_f) fib:set_joinable(true) local _, err = fib:join() - t.assert_equals(tostring(err), "fiber slice is exceeded") + t.assert_equals(err.message, "fiber slice is exceeded") end fiber.set_max_slice(0.2) @@ -92,7 +92,7 @@ g.test_limit_on_sigurg = function() os.execute('kill -URG ' .. tonumber(pid)) local _, err = future:wait_result(1.5) local end_time = clock.monotonic() - t.assert_equals(tostring(err), "fiber slice is exceeded") + t.assert_equals(err.message, "fiber slice is exceeded") -- Must end before slice is over. t.assert(end_time - start_time < 3) end diff --git a/test/box-luatest/gh_7939_fix_meamleak_on_tuple_encode_test.lua b/test/box-luatest/gh_7939_fix_meamleak_on_tuple_encode_test.lua index 4b08dcb188050..1e4a4d7ae31e0 100644 --- a/test/box-luatest/gh_7939_fix_meamleak_on_tuple_encode_test.lua +++ b/test/box-luatest/gh_7939_fix_meamleak_on_tuple_encode_test.lua @@ -176,12 +176,12 @@ g.test_misc_region_leaks = function(cg) } ');]]) t.assert_equals(ret, nil) - t.assert_equals(tostring(err), errmsg) + t.assert_equals(err.message, errmsg) t.assert_equals(before, mem_used()) ret, err = box.execute('SELECT ?;', {{trouble}}) t.assert_equals(ret, nil) - t.assert_equals(tostring(err), errmsg) + t.assert_equals(err.message, errmsg) t.assert_equals(before, mem_used()) end) end diff --git a/test/box-luatest/gh_8802_box_session_push_deprecation_test.lua b/test/box-luatest/gh_8802_box_session_push_deprecation_test.lua index 804499ade56e9..948ab3fc989e1 100644 --- a/test/box-luatest/gh_8802_box_session_push_deprecation_test.lua +++ b/test/box-luatest/gh_8802_box_session_push_deprecation_test.lua @@ -65,7 +65,7 @@ g.test = function(cg) t.assert_equals(ok, compat.box_session_push_deprecation:is_old(), 'box.session.push status') if not ok then - t.assert_equals(tostring(err), 'box.session.push is deprecated', + t.assert_equals(err.message, 'box.session.push is deprecated', 'box.session.push error') end end) @@ -84,7 +84,7 @@ g.test = function(cg) t.assert_equals(ok, compat.box_session_push_deprecation:is_old(), 'box.session.push status') if not ok then - t.assert_equals(tostring(err), 'box.session.push is deprecated', + t.assert_equals(err.message, 'box.session.push is deprecated', 'box.session.push error') end end) diff --git a/test/box-luatest/graceful_shutdown_test.lua b/test/box-luatest/graceful_shutdown_test.lua index bf7bf033b062a..4acb030324a2d 100644 --- a/test/box-luatest/graceful_shutdown_test.lua +++ b/test/box-luatest/graceful_shutdown_test.lua @@ -98,7 +98,7 @@ g.test_discarded_requests_completed = function() g.server:stop() local res, err = fut:result() t.assert_not(res) - t.assert_equals(tostring(err), 'Response is discarded') + t.assert_equals(err.message, 'Response is discarded') t.assert_equals(conn.state, 'error') t.assert_equals(conn.error, 'Peer closed') conn:close() @@ -122,7 +122,7 @@ g.test_hung_requests_aborted = function() g.server:stop() local res, err = fut:result() t.assert_not(res) - t.assert_equals(tostring(err), 'Peer closed') + t.assert_equals(err.message, 'Peer closed') t.assert_equals(conn.state, 'error') t.assert_equals(conn.error, 'Peer closed') conn:close() @@ -161,7 +161,7 @@ g.test_new_requests_not_allowed = function() t.assert_equals(conn.error, 'Peer closed') local res, err = fut:result() t.assert_not(res) - t.assert_equals(tostring(err), 'Peer closed') + t.assert_equals(err.message, 'Peer closed') conn:close() end @@ -504,7 +504,7 @@ g.test_graceful_shutdown_not_supported_by_client = function() g.server:stop() local res, err = fut:result() t.assert_not(res) - t.assert_equals(tostring(err), 'Peer closed') + t.assert_equals(err.message, 'Peer closed') conn:close() end diff --git a/test/box-luatest/net_box_test.lua b/test/box-luatest/net_box_test.lua index 1eb9175dc7365..ec37a99d79da5 100644 --- a/test/box-luatest/net_box_test.lua +++ b/test/box-luatest/net_box_test.lua @@ -348,12 +348,12 @@ g.test_sync_request_in_trigger = function() local function trigger_cb() local status, err status, err = pcall(c.call, c, 'box.session.user', {timeout = 5}) - ch:put(status or tostring(err)) + ch:put(status or err.message) local fut = c:call('box.session.user', {}, {is_async = true}) status, err = pcall(fut.wait_result, fut, 5) - ch:put(status or tostring(err)) + ch:put(status or err.message) status, err = pcall(function() for _, _ in fut:pairs(5) do end end) - ch:put(status or tostring(err)) + ch:put(status or err.message) end local function check() local msg = 'Synchronous requests are not allowed in net.box trigger' diff --git a/test/box-luatest/sending_arbitrary_iproto_packets_test.lua b/test/box-luatest/sending_arbitrary_iproto_packets_test.lua index d63a69fddf5f3..61795c9d1be73 100644 --- a/test/box-luatest/sending_arbitrary_iproto_packets_test.lua +++ b/test/box-luatest/sending_arbitrary_iproto_packets_test.lua @@ -116,10 +116,10 @@ g.test_box_iproto_send_errors = function(cg) s:close() local _, err = pcall(function() box.iproto.send(sid, {}) end) if err ~= nil then - t.assert_str_contains(tostring(err), 'Session is closed') + t.assert_str_contains(err.message, 'Session is closed') else err = _G.test_channel:get() - t.assert_str_contains(tostring(err), 'Session is closed') + t.assert_str_contains(err.message, 'Session is closed') end end) end diff --git a/test/box-tap/gh-5307-key_def-part-count-check.test.lua b/test/box-tap/gh-5307-key_def-part-count-check.test.lua index d9458c95ad9fa..5fbb3d14b247a 100755 --- a/test/box-tap/gh-5307-key_def-part-count-check.test.lua +++ b/test/box-tap/gh-5307-key_def-part-count-check.test.lua @@ -20,7 +20,7 @@ mytest:ok(ok and res < 0, "Simple inequality") -- Should fail local exp_err = "Invalid key part count (expected [0..1], got 9)" ok, res = pcall(kd.compare_with_key, kd, {1}, {1, 2, 3, 4, 5, 6, 7, 8, 9}) -mytest:is_deeply({ok, tostring(res)}, {false, exp_err}, +mytest:is_deeply({ok, res.message}, {false, exp_err}, "Invalid key part count") os.exit(mytest:check() and 0 or 1) diff --git a/test/box-tap/gh-5450-merger-wrong-key-def.test.lua b/test/box-tap/gh-5450-merger-wrong-key-def.test.lua index 033f42da4c1e3..6447eaaf38e74 100755 --- a/test/box-tap/gh-5450-merger-wrong-key-def.test.lua +++ b/test/box-tap/gh-5450-merger-wrong-key-def.test.lua @@ -20,7 +20,7 @@ local exp_err = "Field 6 has type 'string' in one index, but type " .. -- format. local sources = {} local ok, err = pcall(merger.new, key_def, sources) -test:is_deeply({ok, tostring(err)}, {false, exp_err}, +test:is_deeply({ok, err.message}, {false, exp_err}, 'unable to create a tuple format') os.exit(test:check() and 0 or 1) diff --git a/test/box-tap/gh-6198-max-cnt-of-tuple-fields-insert-overflow-err-msg.test.lua b/test/box-tap/gh-6198-max-cnt-of-tuple-fields-insert-overflow-err-msg.test.lua index 4021dc7441650..3ee5ecfdb0a75 100755 --- a/test/box-tap/gh-6198-max-cnt-of-tuple-fields-insert-overflow-err-msg.test.lua +++ b/test/box-tap/gh-6198-max-cnt-of-tuple-fields-insert-overflow-err-msg.test.lua @@ -12,7 +12,7 @@ local t = box.tuple.new({1}):update({{'=', 1, 1}}) local expected_err_msg = 'Tuple field count limit reached: see ' .. 'box.schema.FIELD_MAX' local ok, observed_err_msg = pcall(t.update, t, {{'!', #t, 1}}) -test:is_deeply({ok, tostring(observed_err_msg)}, {false, expected_err_msg}, +test:is_deeply({ok, observed_err_msg.message}, {false, expected_err_msg}, 'unable to insert into a tuple which size equals to ' .. 'box.schema.FIELD_MAX') box.error.injection.set('ERRINJ_TUPLE_FIELD_COUNT_LIMIT', -1) diff --git a/test/box-tap/gh-6295-assert-on-wrong-id.test.lua b/test/box-tap/gh-6295-assert-on-wrong-id.test.lua index add2df4290554..35a8b4daa724b 100755 --- a/test/box-tap/gh-6295-assert-on-wrong-id.test.lua +++ b/test/box-tap/gh-6295-assert-on-wrong-id.test.lua @@ -13,22 +13,22 @@ box.cfg{} local _priv = box.space._priv local errmsg = "Function '1000000' does not exist" ok, res = pcall(_priv.replace, _priv, {1, 2, 'function', 1000000, box.priv.A}) -test:is_deeply({ok, tostring(res)}, {false, errmsg}, "Proper error is returned") +test:is_deeply({ok, res.message}, {false, errmsg}, "Proper error is returned") errmsg = "Sequence '1000000' does not exist" ok, res = pcall(_priv.replace, _priv, {1, 2, 'sequence', 1000000, box.priv.A}) -test:is_deeply({ok, tostring(res)}, {false, errmsg}, "Proper error is returned") +test:is_deeply({ok, res.message}, {false, errmsg}, "Proper error is returned") errmsg = "Space '1000000' does not exist" ok, res = pcall(_priv.replace, _priv, {1, 2, 'space', 1000000, box.priv.A}) -test:is_deeply({ok, tostring(res)}, {false, errmsg}, "Proper error is returned") +test:is_deeply({ok, res.message}, {false, errmsg}, "Proper error is returned") errmsg = "User '1000000' is not found" ok, res = pcall(_priv.replace, _priv, {1, 2, 'user', 1000000, box.priv.A}) -test:is_deeply({ok, tostring(res)}, {false, errmsg}, "Proper error is returned") +test:is_deeply({ok, res.message}, {false, errmsg}, "Proper error is returned") errmsg = "Role '1000000' is not found" ok, res = pcall(_priv.replace, _priv, {1, 2, 'role', 1000000, box.priv.A}) -test:is_deeply({ok, tostring(res)}, {false, errmsg}, "Proper error is returned") +test:is_deeply({ok, res.message}, {false, errmsg}, "Proper error is returned") os.exit(test:check() and 0 or 1) diff --git a/test/box-tap/key_def.test.lua b/test/box-tap/key_def.test.lua index 22e91be543eb4..7a75d7188b180 100755 --- a/test/box-tap/key_def.test.lua +++ b/test/box-tap/key_def.test.lua @@ -214,8 +214,10 @@ for _, case in ipairs(key_def_new_cases) do ffi.istype('struct key_def', res) test:ok(ok, case[1]) else - local err = tostring(res) -- cdata -> string - test:is_deeply({ok, err}, {false, case.exp_err}, case[1]) + if type(res) == 'cdata' then + res = res.message + end + test:is_deeply({ok, res}, {false, case.exp_err}, case[1]) end end end @@ -290,7 +292,7 @@ test:test('extract_key()', function(test) }) local ok, err = pcall(key_def.extract_key, key_def, box.tuple.new({'foo'})) - test:is_deeply({ok, tostring(err)}, {false, exp_err}, + test:is_deeply({ok, err.message}, {false, exp_err}, 'short tuple with a non-nullable part (case 1)') -- Same as before, but a max fieldno is over tuple:len() + 1. @@ -302,7 +304,7 @@ test:test('extract_key()', function(test) }) local ok, err = pcall(key_def.extract_key, key_def, box.tuple.new({'foo'})) - test:is_deeply({ok, tostring(err)}, {false, exp_err}, + test:is_deeply({ok, err.message}, {false, exp_err}, 'short tuple with a non-nullable part (case 2)') -- Same as before, but with another key def options: @@ -316,7 +318,7 @@ test:test('extract_key()', function(test) }) local ok, err = pcall(key_def.extract_key, key_def, box.tuple.new({'foo'})) - test:is_deeply({ok, tostring(err)}, {false, exp_err}, + test:is_deeply({ok, err.message}, {false, exp_err}, 'short tuple with a non-nullable part (case 3)') -- A tuple has a field that does not match corresponding key @@ -329,7 +331,7 @@ test:test('extract_key()', function(test) {type = 'string', fieldno = 3}, }) local ok, err = pcall(key_def.extract_key, key_def, {'one', 'two', 3}) - test:is_deeply({ok, tostring(err)}, {false, exp_err}, + test:is_deeply({ok, err.message}, {false, exp_err}, 'wrong field type') local key_def = key_def_lib.new({ @@ -340,7 +342,7 @@ test:test('extract_key()', function(test) }) local ok, err = pcall(key_def.extract_key, key_def, box.tuple.new({1, 1, 22})) - test:is_deeply({ok, tostring(err)}, + test:is_deeply({ok, err.message}, {false, 'Tuple field [1]a required by space format is missing'}, 'invalid JSON structure') test:is_deeply(key_def:extract_key({{a=1, b=2}, 1}):totable(), @@ -393,7 +395,7 @@ test:test('compare()', function(test) {type = 'array', fieldno = 2, is_nullable = true}, }) local ok, err = pcall(key_def.compare, key_def, {'aa', {}}, {'bb', box.NULL}) - test:is_deeply({ok, tostring(err)}, {false, cmp_err}, 'no composite comparison') + test:is_deeply({ok, err.message}, {false, cmp_err}, 'no composite comparison') end) -- Case: compare_with_key(). @@ -418,13 +420,13 @@ test:test('compare_with_key()', function(test) {type = 'map', fieldno = 2}, }) local ok, err = pcall(key_def.compare_with_key, key_def, {'aa', {}}, {'bb', box.NULL}) - test:is_deeply({ok, tostring(err)}, {false, cmp_err}, 'no composite comparison') + test:is_deeply({ok, err.message}, {false, cmp_err}, 'no composite comparison') -- Unserializable key. local exp_err = "unsupported Lua type 'function'" local key = {function() end} local ok, err = pcall(key_def_b.compare_with_key, key_def_b, tuple_a, key) - test:is_deeply({ok, tostring(err)}, {false, exp_err}, 'unserializable key') + test:is_deeply({ok, err.message}, {false, exp_err}, 'unserializable key') end) -- Case: totable(). diff --git a/test/box-tap/merger.test.lua b/test/box-tap/merger.test.lua index f22aaa5c5b85f..b012ac7f4bed6 100755 --- a/test/box-tap/merger.test.lua +++ b/test/box-tap/merger.test.lua @@ -593,7 +593,9 @@ end for _, case in ipairs(bad_merger_select_calls) do local merger_inst = merger.new(key_def, case.sources) local ok, err = pcall(merger_inst.select, merger_inst, case.opts) - err = tostring(err) -- cdata -> string + if not ok and type(err) == 'cdata' then + err = err.message -- cdata -> string + end test:is_deeply({ok, err}, {false, case.exp_err}, case[1]) end diff --git a/test/box-tap/several-listening-sockets.test.lua b/test/box-tap/several-listening-sockets.test.lua index 4ad5c98c72813..37be44602675b 100755 --- a/test/box-tap/several-listening-sockets.test.lua +++ b/test/box-tap/several-listening-sockets.test.lua @@ -99,9 +99,9 @@ local uri_table, errmsg local function test_error_message(uri_table, errmsg) errmsg = "Incorrect value for option 'listen': " .. errmsg local _, err = pcall(box.cfg, {listen = uri_table}) - test:is(tostring(err), errmsg, "error message") + test:is(err.message, errmsg, "error message") _, err = pcall(box.cfg, {listen = uri_table}) - test:is(tostring(err), errmsg, "error message") + test:is(err.message, errmsg, "error message") end -- Incorrect URI: expected host:service or /unix.socket diff --git a/test/box/errinj.test.lua b/test/box/errinj.test.lua index 78047408d658e..2695d2d2c5736 100644 --- a/test/box/errinj.test.lua +++ b/test/box/errinj.test.lua @@ -290,7 +290,7 @@ cn:ping() errinj.set('ERRINJ_PORT_DUMP', true) ok, ret = pcall(cn.space._space.select, cn.space._space) assert(not ok) -assert(string.match(tostring(ret), 'Failed to allocate')) +assert(string.match(ret.message, 'Failed to allocate')) errinj.set('ERRINJ_PORT_DUMP', false) cn:close() box.schema.user.revoke('guest', 'read', 'space', '_space') diff --git a/test/box/func_reload.result b/test/box/func_reload.result index eaa07dccad017..d25069af3bb69 100644 --- a/test/box/func_reload.result +++ b/test/box/func_reload.result @@ -244,7 +244,7 @@ os.setenv("TMPDIR", "/dev/null") _, err = pcall(box.schema.func.reload, "reload") --- ... -tostring(err):gsub(': [/%w]+:', ':') +err.message:gsub(': [/%w]+:', ':') --- - 'failed to create unique dir name: Not a directory' - 1 diff --git a/test/box/func_reload.test.lua b/test/box/func_reload.test.lua index 3a0bc721e19f9..aa305cd1e7392 100644 --- a/test/box/func_reload.test.lua +++ b/test/box/func_reload.test.lua @@ -86,7 +86,7 @@ box.schema.func.reload("non-existing") -- path for DSO copy os.setenv("TMPDIR", "/dev/null") _, err = pcall(box.schema.func.reload, "reload") -tostring(err):gsub(': [/%w]+:', ':') +err.message:gsub(': [/%w]+:', ':') os.setenv("TMPDIR", nil) box.schema.func.drop("reload.test_reload") diff --git a/test/box/net.box_long-poll_input_gh-3400.result b/test/box/net.box_long-poll_input_gh-3400.result index 57c6757ec27f0..90aa9b5ede93e 100644 --- a/test/box/net.box_long-poll_input_gh-3400.result +++ b/test/box/net.box_long-poll_input_gh-3400.result @@ -45,7 +45,7 @@ test_run:wait_cond(function() return f:status() == 'dead' end) --- - true ... -assert(tostring(result) == 'Peer closed') +assert(result.message == 'Peer closed') --- - true ... diff --git a/test/box/net.box_long-poll_input_gh-3400.test.lua b/test/box/net.box_long-poll_input_gh-3400.test.lua index cf3a6b459f1d5..2cda8cf0014d8 100644 --- a/test/box/net.box_long-poll_input_gh-3400.test.lua +++ b/test/box/net.box_long-poll_input_gh-3400.test.lua @@ -23,5 +23,5 @@ end) pcall(c._request, c, 'INJECT', nil, nil, nil, '\x80') test_run:cmd("setopt delimiter ''"); test_run:wait_cond(function() return f:status() == 'dead' end) -assert(tostring(result) == 'Peer closed') +assert(result.message == 'Peer closed') c:close() diff --git a/test/engine/errinj_ddl.result b/test/engine/errinj_ddl.result index 631aa5fc68c04..794513d64c196 100644 --- a/test/engine/errinj_ddl.result +++ b/test/engine/errinj_ddl.result @@ -347,7 +347,7 @@ assert(not ok) --- - true ... -assert(tostring(err):find('Duplicate key') ~= nil) +assert(err.message:find('Duplicate key') ~= nil) --- - true ... diff --git a/test/engine/errinj_ddl.test.lua b/test/engine/errinj_ddl.test.lua index dff72aec82cbf..219d56ea79a23 100644 --- a/test/engine/errinj_ddl.test.lua +++ b/test/engine/errinj_ddl.test.lua @@ -160,7 +160,7 @@ test_run:cmd("setopt delimiter ''"); errinj.set("ERRINJ_BUILD_INDEX_DELAY", true) ok, err = pcall(s.create_index, s, 'sk', {parts = {2, 'unsigned'}}) assert(not ok) -assert(tostring(err):find('Duplicate key') ~= nil) +assert(err.message:find('Duplicate key') ~= nil) ch:get() diff --git a/test/interactive_tarantool.lua b/test/interactive_tarantool.lua index 5243800b0d731..30a0d19877049 100644 --- a/test/interactive_tarantool.lua +++ b/test/interactive_tarantool.lua @@ -33,7 +33,7 @@ function mt._start_stderr_logger(self) local chunk, err = self.ph:read({stderr = true}) if chunk == nil then log.warn(('%s: got error, exitting: %s'):format( - fiber_name, tostring(err))) + fiber_name, err.message)) break end if chunk == '' then @@ -123,7 +123,7 @@ function mt.read_until_prompt(self, opts) local stderr, err = self.ph:read({timeout = 0.05, stderr = true}) if stderr ~= "" and not (stderr == nil and - tostring(err) == "timed out") then + err.message == "timed out") then error(("Unexpected stderr output: %s"):format(stderr)) end diff --git a/test/justrun.lua b/test/justrun.lua index 953b53fefe90a..dbe79f3c151f4 100644 --- a/test/justrun.lua +++ b/test/justrun.lua @@ -17,7 +17,7 @@ local function collect_stderr(ph) local chunk, err = ph:read({stderr = true}) if chunk == nil then log.warn(('%s: got error, exiting: %s'):format( - fiber_name, tostring(err))) + fiber_name, err.message)) break end if chunk == '' then diff --git a/test/sql-tap/gh2250-trigger-chain-limit.test.lua b/test/sql-tap/gh2250-trigger-chain-limit.test.lua index 53c726405f084..032a5d7e390fe 100755 --- a/test/sql-tap/gh2250-trigger-chain-limit.test.lua +++ b/test/sql-tap/gh2250-trigger-chain-limit.test.lua @@ -75,12 +75,11 @@ for _, table_count in ipairs({30, 31}) do local function check(sql) local _, msg = pcall(function () test:execsql(sql) end) - msg = tostring(msg) test:do_test(sql, function() return true end, - table_count <= 30 or msg == 'Maximum number of chained trigger activations exceeded.') + table_count <= 30 or msg.message == 'Maximum number of chained trigger activations exceeded.') end -- Exceed check for UPDATE diff --git a/test/vinyl-luatest/gh_7240_abort_yielding_dml_test.lua b/test/vinyl-luatest/gh_7240_abort_yielding_dml_test.lua index ccb6374113f7a..de008a7d9d245 100644 --- a/test/vinyl-luatest/gh_7240_abort_yielding_dml_test.lua +++ b/test/vinyl-luatest/gh_7240_abort_yielding_dml_test.lua @@ -40,7 +40,7 @@ g.test_abort_yielding_dml = function(cg) local ch = fiber.channel(1) fiber.create(function() local ok, err = pcall(s.insert, s, {2, 20}) - ch:put(ok or tostring(err)) + ch:put(ok or err.message) end) -- The insert operation blocks on disk read to check uniqueness. t.assert_is(ch:get(0.1), nil)