aboutsummaryrefslogtreecommitdiff
path: root/test/helpers.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2024-01-15 20:21:14 +0000
committerLewis Russell <lewis6991@gmail.com>2024-01-17 10:10:17 +0000
commitb92318d67cf28e31e15ec318d7f3803986cdd5ce (patch)
treedf18341a12e348d867e530aaebc258897020ff98 /test/helpers.lua
parentc9240daf73bb73d45633670f945ce3c6e780c8ad (diff)
downloadrneovim-b92318d67cf28e31e15ec318d7f3803986cdd5ce.tar.gz
rneovim-b92318d67cf28e31e15ec318d7f3803986cdd5ce.tar.bz2
rneovim-b92318d67cf28e31e15ec318d7f3803986cdd5ce.zip
test: improve helpers.argss_to_cmd()
Diffstat (limited to 'test/helpers.lua')
-rw-r--r--test/helpers.lua10
1 files changed, 6 insertions, 4 deletions
diff --git a/test/helpers.lua b/test/helpers.lua
index c2cb7de6c8..1e9160f543 100644
--- a/test/helpers.lua
+++ b/test/helpers.lua
@@ -42,20 +42,22 @@ function module.isdir(path)
return stat.type == 'directory'
end
+--- @param ... string|string[]
--- @return string
function module.argss_to_cmd(...)
- local cmd = ''
+ local cmd = {} --- @type string[]
for i = 1, select('#', ...) do
local arg = select(i, ...)
if type(arg) == 'string' then
- cmd = cmd .. ' ' .. shell_quote(arg)
+ cmd[#cmd + 1] = shell_quote(arg)
else
+ --- @cast arg string[]
for _, subarg in ipairs(arg) do
- cmd = cmd .. ' ' .. shell_quote(subarg)
+ cmd[#cmd + 1] = shell_quote(subarg)
end
end
end
- return cmd
+ return table.concat(cmd, ' ')
end
function module.popen_r(...)