From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id E09D14696C3 for ; Wed, 25 Dec 2019 19:09:18 +0300 (MSK) Received: by mail-lf1-f44.google.com with SMTP id f15so17008957lfl.13 for ; Wed, 25 Dec 2019 08:09:18 -0800 (PST) From: Cyrill Gorcunov Date: Wed, 25 Dec 2019 19:08:53 +0300 Message-Id: <20191225160853.1407-3-gorcunov@gmail.com> In-Reply-To: <20191225160853.1407-1-gorcunov@gmail.com> References: <20191225160853.1407-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 2/2] box/console: handle empty output format List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml In case if output format is not specified we should exit with more readable error message. Fixes #4638 Signed-off-by: Cyrill Gorcunov --- 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