From c265f9137c47f340d4848988c6944f3b76ecce37 Mon Sep 17 00:00:00 2001 From: Roman Tsisyk <roman@tsisyk.com> Date: Wed, 6 May 2015 17:51:07 +0300 Subject: [PATCH] Follow up console fixes Add forgotten .result files --- src/lua/net_box.lua | 3 + test/box/net.box.result | 131 ++++++++++++++++---------------------- test/box/net.box.test.lua | 50 ++++----------- 3 files changed, 70 insertions(+), 114 deletions(-) diff --git a/src/lua/net_box.lua b/src/lua/net_box.lua index 5ccd8bc22f..cc7834a04d 100644 --- a/src/lua/net_box.lua +++ b/src/lua/net_box.lua @@ -1091,6 +1091,9 @@ remote.self = { return result end, eval = function(_box, expr, ...) + if type(_box) ~= 'table' then + box.error(box.error.PROC_LUA, "usage: remote:eval(expr, ...)") + end local proc, errmsg = loadstring(expr) if not proc then proc, errmsg = loadstring("return "..expr) diff --git a/test/box/net.box.result b/test/box/net.box.result index 7c66df2f35..dca0af0510 100644 --- a/test/box/net.box.result +++ b/test/box/net.box.result @@ -232,7 +232,7 @@ cn.space.net_box_test_space:insert{234, 1,2,3} ... cn.space.net_box_test_space.insert{234, 1,2,3} --- -- error: 'builtin/net.box.lua:242: Use space:method(...) instead space.method(...)' +- error: 'builtin/net.box.lua:243: Use space:method(...) instead space.method(...)' ... cn.space.net_box_test_space:replace{354, 1,2,3} --- @@ -617,79 +617,50 @@ space:drop() --- ... -- admin console tests -function console_test(...) return { ... } end +cnc = remote:new(os.getenv('ADMIN')) --- ... -function console_test_error(...) error(string.format(...)) end ---- -... -function console_unpack_test(...) return ... end ---- -... -ADMIN = require('uri').parse(os.getenv('ADMIN')) ---- -... -cn = remote:new(LISTEN.host, LISTEN.service) ---- -... -cnc = remote:new(ADMIN.host, ADMIN.service) ---- -... -cnc.console +cnc.console ~= nil --- - true ... -cn:call('console_test', 1, 2, 3, 'string', nil) ---- -- - [1, 2, 3, 'string'] -... -cnc:call('console_test', 1, 2, 3, 'string', nil) ---- -- - [1, 2, 3, 'string'] -... -cn:call('console_test_error', 'error %d', 123) ---- -- error: '[string "function console_test_error(...) error(string..."]:1: error 123' -... -cnc:call('console_test_error', 'error %d', 123) ---- -- error: '[string "function console_test_error(...) error(string..."]:1: error 123' -... -cn:call('console_unpack_test', 1) ---- -- - [1] -... -cnc:call('console_unpack_test', 1) ---- -- - [1] -... -cn:call('123') ---- -- error: Procedure '123' is not defined -... -cnc:call('123') ---- -- error: '[string "123()"]:1: unexpected symbol near ''123''' -... --- gh-649: String escaping doesn't work in remote console -function echo(...) return ... end ---- -... -#cn:call('echo', [[a \[\[ \091\091 b \093\093 c \n d \t e \]\] f ]])[1][1] ---- -- 46 -... -#cnc:call('echo', [[a \[\[ \091\091 b \093\093 c \n d \t e \]\] f ]])[1][1] ---- -- 46 -... -#cn:call('echo', "a [[ \091\091 b \093\093 c \n d \t e ]] f ")[1][1] ---- -- 28 -... -#cnc:call('echo', "a [[ \091\091 b \093\093 c \n d \t e ]] f ")[1][1] ---- -- 28 +cnc:console('return 1, 2, 3, "string", nil') +--- +- '--- + + - 1 + + - 2 + + - 3 + + - string + + - null + + ... + +' +... +cnc:console('error("test")') +--- +- '--- + + - error: test + + ... + +' +... +cnc:console('a = {1, 2, 3, 4}; return a[3]') +--- +- '--- + + - 3 + + ... + +' ... -- #545 user or password is not defined remote:new(LISTEN.host, LISTEN.service, { user = 'test' }) @@ -701,25 +672,31 @@ remote:new(LISTEN.host, LISTEN.service, { password = 'test' }) - error: 'net.box: user is not defined' ... -- #544 usage for remote[point]method -cn:call('console_test') +cn = remote:new(LISTEN.host, LISTEN.service) --- -- - [] ... -cn.call('console_test') +cn:eval('return true') +--- +- true +... +cn.eval('return true') --- -- error: 'usage: remote:call(proc_name, ...)' +- error: 'usage: remote:eval(expr, ...)' ... cn.ping() --- - error: 'usage: remote:ping()' ... -remote.self:call('console_test') +cn:close() --- -- [] ... -remote.self.call('console_test') +remote.self:eval('return true') +--- +- true +... +remote.self.eval('return true') --- -- error: 'usage: remote:call(proc_name, ...)' +- error: 'usage: remote:eval(expr, ...)' ... -- uri as the first argument uri = string.format('%s:%s@%s:%s', 'netbox', 'test', LISTEN.host, LISTEN.service) diff --git a/test/box/net.box.test.lua b/test/box/net.box.test.lua index 7c2d0d5a00..47cbda5ba9 100644 --- a/test/box/net.box.test.lua +++ b/test/box/net.box.test.lua @@ -225,52 +225,28 @@ space:drop() -- admin console tests -function console_test(...) return { ... } end -function console_test_error(...) error(string.format(...)) end -function console_unpack_test(...) return ... end - - -ADMIN = require('uri').parse(os.getenv('ADMIN')) - -cn = remote:new(LISTEN.host, LISTEN.service) -cnc = remote:new(ADMIN.host, ADMIN.service) -cnc.console - -cn:call('console_test', 1, 2, 3, 'string', nil) -cnc:call('console_test', 1, 2, 3, 'string', nil) - -cn:call('console_test_error', 'error %d', 123) -cnc:call('console_test_error', 'error %d', 123) - - -cn:call('console_unpack_test', 1) -cnc:call('console_unpack_test', 1) - - - - -cn:call('123') -cnc:call('123') - --- gh-649: String escaping doesn't work in remote console -function echo(...) return ... end -#cn:call('echo', [[a \[\[ \091\091 b \093\093 c \n d \t e \]\] f ]])[1][1] -#cnc:call('echo', [[a \[\[ \091\091 b \093\093 c \n d \t e \]\] f ]])[1][1] -#cn:call('echo', "a [[ \091\091 b \093\093 c \n d \t e ]] f ")[1][1] -#cnc:call('echo', "a [[ \091\091 b \093\093 c \n d \t e ]] f ")[1][1] +cnc = remote:new(os.getenv('ADMIN')) +cnc.console ~= nil +cnc:console('return 1, 2, 3, "string", nil') +cnc:console('error("test")') +cnc:console('a = {1, 2, 3, 4}; return a[3]') -- #545 user or password is not defined remote:new(LISTEN.host, LISTEN.service, { user = 'test' }) remote:new(LISTEN.host, LISTEN.service, { password = 'test' }) -- #544 usage for remote[point]method -cn:call('console_test') -cn.call('console_test') +cn = remote:new(LISTEN.host, LISTEN.service) + +cn:eval('return true') +cn.eval('return true') cn.ping() -remote.self:call('console_test') -remote.self.call('console_test') +cn:close() + +remote.self:eval('return true') +remote.self.eval('return true') -- uri as the first argument -- GitLab