[Tarantool-patches] [PATCH 2/2] box/console: handle empty output format

Cyrill Gorcunov gorcunov at gmail.com
Wed Dec 25 19:08:53 MSK 2019


In case if output format is not specified we should exit
with more readable error message.

Fixes #4638

Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
 src/box/lua/console.lua           | 3 +++
 test/app-tap/console-lua.test.lua | 8 +++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua
index a4a36c625..17e2c91b2 100644
--- a/src/box/lua/console.lua
+++ b/src/box/lua/console.lua
@@ -126,6 +126,9 @@ end
 
 local function parse_output(value)
     local fmt, opts
+    if not value then
+        return 'Specify output format: lua or yaml.'
+    end
     if value:match("([^,]+),([^,]+)") ~= nil then
         fmt, opts = value:match("([^,]+),([^,]+)")
     else
diff --git a/test/app-tap/console-lua.test.lua b/test/app-tap/console-lua.test.lua
index d3271a369..837e8ea18 100755
--- a/test/app-tap/console-lua.test.lua
+++ b/test/app-tap/console-lua.test.lua
@@ -20,7 +20,7 @@ local EOL = ";"
 
 test = tap.test("console-lua")
 
-test:plan(7)
+test:plan(8)
 
 --
 -- Start console and connect to it
@@ -45,6 +45,12 @@ test:is(client:read(EOL), EOL, "declare array")
 client:write('1,2,nil,a\n')
 test:is(client:read(EOL), '1, 2, box.NULL, {1, 2, 3}' .. EOL, "multireturn numbers")
 
+--
+-- Try to setup empty output mode
+client:write('\\set output\n')
+test:is(client:read(EOL), '\"Specify output format: lua or yaml.\"' .. EOL,
+        "set empty output mode")
+
 --
 -- Disconect from console
 client:shutdown()
-- 
2.20.1



More information about the Tarantool-patches mailing list