aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarcos Almeida <maurelio1234@users.noreply.github.com>2018-07-29 03:49:11 +0200
committerJustin M. Keyes <justinkz@gmail.com>2018-07-29 03:49:11 +0200
commita2253744c9bcd9229be9533540075e977f0be2cd (patch)
tree070c1e53b0578e99bcb0b8dcb2c56b5b7b821ba8 /test
parentbefc7de26f2907fdf0c61b883c68c7a64432aa03 (diff)
downloadrneovim-a2253744c9bcd9229be9533540075e977f0be2cd.tar.gz
rneovim-a2253744c9bcd9229be9533540075e977f0be2cd.tar.bz2
rneovim-a2253744c9bcd9229be9533540075e977f0be2cd.zip
system(): handle profiling and 'verbose' #8730
closes #8362 Vim's code calls `call_shell` directly from `get_system_output_as_rettv` whereas in Nvim this function has been rewritten to not call `call_shell` but to call `os_system` via `do_os_system`, losing the support for profiling and verbose. Changing the code to call `call_shell` from `get_system_output_as_rettv` seems to be too complicated to be worth it on the current version of the code. So this commit duplicates the relevant code.
Diffstat (limited to 'test')
-rw-r--r--test/functional/eval/system_spec.lua42
-rw-r--r--test/functional/helpers.lua2
-rw-r--r--test/helpers.lua4
3 files changed, 48 insertions, 0 deletions
diff --git a/test/functional/eval/system_spec.lua b/test/functional/eval/system_spec.lua
index 5e12b6a6a4..03aa7fa45f 100644
--- a/test/functional/eval/system_spec.lua
+++ b/test/functional/eval/system_spec.lua
@@ -203,6 +203,48 @@ describe('system()', function()
]])
end)
+ it('prints verbose information', function()
+ feed(':4verbose echo system("echo hi")<cr>')
+ screen:expect([[
+ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ Calling shell to execute: "echo hi" |
+ |
+ hi |
+ |
+ Press ENTER or type command to continue^ |
+ ]])
+ feed('<cr>')
+ end)
+
+ it('self and total time recorded separately', function()
+ local tempfile = helpers.tmpname()
+
+ feed(':function! AlmostNoSelfTime()<cr>')
+ feed('echo system("echo hi")<cr>')
+ feed('endfunction<cr>')
+
+ feed(':profile start ' .. tempfile .. '<cr>')
+ feed(':profile func AlmostNoSelfTime<cr>')
+ feed(':call AlmostNoSelfTime()<cr>')
+ feed(':profile dump<cr>')
+
+ feed(':edit ' .. tempfile .. '<cr>')
+
+ local command_total_time = tonumber(helpers.funcs.split(helpers.funcs.getline(7))[2])
+ local command_self_time = tonumber(helpers.funcs.split(helpers.funcs.getline(7))[3])
+
+ helpers.neq(nil, command_total_time)
+ helpers.neq(nil, command_self_time)
+ end)
+
it('`yes` interrupted with CTRL-C', function()
feed(':call system("' .. (iswin()
and 'for /L %I in (1,0,2) do @echo y'
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index a6d2764187..72e71a2cf2 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -18,6 +18,7 @@ local expect_err = global_helpers.expect_err
local filter = global_helpers.filter
local map = global_helpers.map
local matches = global_helpers.matches
+local near = global_helpers.near
local neq = global_helpers.neq
local ok = global_helpers.ok
local read_file = global_helpers.read_file
@@ -699,6 +700,7 @@ local module = {
meths = meths,
missing_provider = missing_provider,
mkdir = lfs.mkdir,
+ near = near,
neq = neq,
new_pipename = new_pipename,
next_msg = next_msg,
diff --git a/test/helpers.lua b/test/helpers.lua
index a774a67df3..66724f6a78 100644
--- a/test/helpers.lua
+++ b/test/helpers.lua
@@ -54,6 +54,9 @@ end
local function ok(res)
return assert.is_true(res)
end
+local function near(actual, expected, tolerance)
+ return assert.is.near(actual, expected, tolerance)
+end
local function matches(pat, actual)
if nil ~= string.match(actual, pat) then
return true
@@ -694,6 +697,7 @@ local module = {
map = map,
matches = matches,
mergedicts_copy = mergedicts_copy,
+ near = near,
neq = neq,
ok = ok,
popen_r = popen_r,