aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/eval/system_spec.lua22
-rw-r--r--test/functional/ui/screen.lua2
-rw-r--r--test/unit/os/shell_spec.lua31
3 files changed, 38 insertions, 17 deletions
diff --git a/test/functional/eval/system_spec.lua b/test/functional/eval/system_spec.lua
index 0d84f47b65..5cbf34365b 100644
--- a/test/functional/eval/system_spec.lua
+++ b/test/functional/eval/system_spec.lua
@@ -203,23 +203,13 @@ describe('system()', function()
end)
it('prints verbose information', function()
+ screen:try_resize(72, 14)
feed(':4verbose echo system("echo hi")<cr>')
- screen:expect([[
- |
- ~ |
- ~ |
- ~ |
- ~ |
- ~ |
- ~ |
- ~ |
- |
- Calling shell to execute: "echo hi" |
- |
- hi |
- |
- Press ENTER or type command to continue^ |
- ]])
+ if iswin() then
+ screen:expect{any=[[Executing command: "'cmd.exe' '/s' '/c' '"echo hi"'"]]}
+ else
+ screen:expect{any=[[Executing command: "'/[^']*sh' '%-c' 'echo hi'"]]}
+ end
feed('<cr>')
end)
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index 364b65c581..3831968f5b 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -243,7 +243,7 @@ local ext_keys = {
-- nothing is ignored.
-- condition: Function asserting some arbitrary condition. Return value is
-- ignored, throw an error (use eq() or similar) to signal failure.
--- any: A string that should be present on any line of the screen.
+-- any: Lua pattern string expected to match a screen line.
-- mode: Expected mode as signaled by "mode_change" event
--
-- The following keys should be used to expect the state of various ext_
diff --git a/test/unit/os/shell_spec.lua b/test/unit/os/shell_spec.lua
index 37274502de..a73fc8e47e 100644
--- a/test/unit/os/shell_spec.lua
+++ b/test/unit/os/shell_spec.lua
@@ -25,6 +25,7 @@ describe('shell functions', function()
local res = cimported.shell_build_argv(
cmd and to_cstr(cmd),
extra_args and to_cstr(extra_args))
+ -- `res` is zero-indexed (C pointer, not Lua table)!
local argc = 0
local ret = {}
-- Explicitly free everything, so if it is not in allocated memory it will
@@ -38,6 +39,26 @@ describe('shell functions', function()
return ret
end
+ local function shell_argv_to_str(argv_table)
+ -- C string array (char **).
+ local argv = (argv_table
+ and ffi.new("char*[?]", #argv_table+1)
+ or NULL)
+
+ local argc = 1
+ while argv_table ~= nil and argv_table[argc] ~= nil do
+ -- `argv` is zero-indexed (C pointer, not Lua table)!
+ argv[argc - 1] = to_cstr(argv_table[argc])
+ argc = argc + 1
+ end
+ if argv_table ~= nil then
+ argv[argc - 1] = NULL
+ end
+
+ local res = cimported.shell_argv_to_str(argv)
+ return ffi.string(res)
+ end
+
local function os_system(cmd, input)
local input_or = input and to_cstr(input) or NULL
local input_len = (input ~= nil) and string.len(input) or 0
@@ -151,4 +172,14 @@ describe('shell functions', function()
eq(nil, argv[3])
end)
end)
+
+ itp('shell_argv_to_str', function()
+ eq('', shell_argv_to_str({ nil }))
+ eq("''", shell_argv_to_str({ '' }))
+ eq("'foo' '' 'bar'", shell_argv_to_str({ 'foo', '', 'bar' }))
+ eq("'/bin/sh' '-c' 'abc def'", shell_argv_to_str({'/bin/sh', '-c', 'abc def'}))
+ eq("'abc def' 'ghi jkl'", shell_argv_to_str({'abc def', 'ghi jkl'}))
+ eq("'/bin/sh' '-c' 'abc def' '"..('x'):rep(225).."...",
+ shell_argv_to_str({'/bin/sh', '-c', 'abc def', ('x'):rep(999)}))
+ end)
end)