forked from tarantool/tarantool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
console: add line carrying backslash
When using interactive console(stdin) instead of `\set delimiter '\'`, slash at the end of the line can be used. Works on both server and client side. Co-authored-by: Olga Arkhangelskaia <arkholga@tarantool.org> Closes tarantool#4317 Requires tarantool#7357 @TarantoolBot document Title: introduce line carrying slash Now we can use multiline commands with lines ending with '\' by default. Works only without a set delimiter. Consider the example: ``` tarantool> a = 10 \ > + 12 --- ... tarantool> a --- - 22 ... ```
- Loading branch information
Showing
3 changed files
with
89 additions
and
3 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
changelogs/unreleased/gh-4317-console-add-line-carrying-backslash.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## feature/console | ||
|
||
* Now multiline commands with each line ending with "\" can be used instead | ||
of `\set delimiter "\"`, is active only without a set delimiter. Works on | ||
both server and client side. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
local t = require('luatest') | ||
local g = t.group() | ||
|
||
local result_str = [[tarantool> local a = 0 \ | ||
> for i = 1, 10 do | ||
> a = a + i | ||
> end \ | ||
> print(a) | ||
55 | ||
--- | ||
... | ||
tarantool> ]] | ||
|
||
g.test_local_console = function() | ||
local build_dir = arg[-1]:gsub('tarantool$', '') | ||
local tarantool_command = [[local a = 0 \\\nfor i = 1, 10 do\na = a + i\nend \\\nprint(a)\n]] | ||
|
||
local cmd = ("printf '%s' | tarantool -i 2>/dev/null"):format(tarantool_command) | ||
local fh = io.popen(cmd, 'r') | ||
|
||
-- Readline on CentOS 7 produces \e[?1034h escape sequence before tarantool> prompt, remove it. | ||
local result = fh:read('*a'):gsub('\x1b%[%?1034h', '') | ||
|
||
fh:close() | ||
t.assert_equals(result, result_str) | ||
end | ||
|
||
g.test_remote_console = function() | ||
local console = require('console') | ||
local socket = require('socket') | ||
local log = require('log') | ||
|
||
-- Suppress console log messages. | ||
log.level(4) | ||
local CONSOLE_SOCKET = '/tmp/tarantool-test-console.sock' | ||
local IPROTO_SOCKET = '/tmp/tarantool-test-iproto.sock' | ||
local EOL = '\n...\n' | ||
console.listen(CONSOLE_SOCKET) | ||
socket.tcp_connect('unix/', CONSOLE_SOCKET) | ||
local tarantool_command = 'local a = 0 \\\nfor i = 1, 10 do\\\n a = a + i \\\n end \\\n print(a)' | ||
|
||
local client = socket.tcp_connect('unix/', CONSOLE_SOCKET) | ||
client:read(128) | ||
client:write(('%s\n'):format(tarantool_command)) | ||
local result = client:read(EOL) | ||
t.assert_not_str_contains(result, 'error') | ||
client:close() | ||
os.remove(CONSOLE_SOCKET) | ||
os.remove(IPROTO_SOCKET) | ||
end |