aboutsummaryrefslogtreecommitdiff
path: root/test/functional/vimscript/system_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/vimscript/system_spec.lua')
-rw-r--r--test/functional/vimscript/system_spec.lua76
1 files changed, 35 insertions, 41 deletions
diff --git a/test/functional/vimscript/system_spec.lua b/test/functional/vimscript/system_spec.lua
index d44f68e152..792e4c46c3 100644
--- a/test/functional/vimscript/system_spec.lua
+++ b/test/functional/vimscript/system_spec.lua
@@ -1,26 +1,20 @@
-- Tests for system() and :! shell.
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.testutil')
+local n = require('test.functional.testnvim')()
+local Screen = require('test.functional.ui.screen')
-local assert_alive = helpers.assert_alive
-local testprg = helpers.testprg
+local assert_alive = n.assert_alive
+local testprg = n.testprg
local eq, call, clear, eval, feed_command, feed, api =
- helpers.eq,
- helpers.call,
- helpers.clear,
- helpers.eval,
- helpers.feed_command,
- helpers.feed,
- helpers.api
-local command = helpers.command
-local insert = helpers.insert
-local expect = helpers.expect
-local exc_exec = helpers.exc_exec
-local os_kill = helpers.os_kill
-local pcall_err = helpers.pcall_err
-local is_os = helpers.is_os
-
-local Screen = require('test.functional.ui.screen')
+ t.eq, n.call, n.clear, n.eval, n.feed_command, n.feed, n.api
+local command = n.command
+local insert = n.insert
+local expect = n.expect
+local exc_exec = n.exc_exec
+local os_kill = n.os_kill
+local pcall_err = t.pcall_err
+local is_os = t.is_os
local function create_file_with_nuls(name)
return function()
@@ -189,7 +183,7 @@ describe('system()', function()
end)
it('with powershell', function()
- helpers.set_shell_powershell()
+ n.set_shell_powershell()
eq('a\nb\n', eval([[system('Write-Output a b')]]))
eq('C:\\\n', eval([[system('cd c:\; (Get-Location).Path')]]))
eq('a b\n', eval([[system('Write-Output "a b"')]]))
@@ -197,11 +191,11 @@ describe('system()', function()
end
it('powershell w/ UTF-8 text #13713', function()
- if not helpers.has_powershell() then
+ if not n.has_powershell() then
pending('powershell not found', function() end)
return
end
- helpers.set_shell_powershell()
+ n.set_shell_powershell()
eq('ああ\n', eval([[system('Write-Output "ああ"')]]))
-- Sanity test w/ default encoding
-- * on Windows, expected to default to Western European enc
@@ -214,7 +208,7 @@ describe('system()', function()
feed(':call system("echo")<cr>')
screen:expect([[
^ |
- ~ |*12
+ {1:~ }|*12
:call system("echo") |
]])
end)
@@ -234,7 +228,7 @@ describe('system()', function()
end)
it('self and total time recorded separately', function()
- local tempfile = helpers.tmpname()
+ local tempfile = t.tmpname()
feed(':function! AlmostNoSelfTime()<cr>')
feed('echo system("echo hi")<cr>')
@@ -247,11 +241,11 @@ describe('system()', function()
feed(':edit ' .. tempfile .. '<cr>')
- local command_total_time = tonumber(helpers.fn.split(helpers.fn.getline(7))[2])
- local command_self_time = tonumber(helpers.fn.split(helpers.fn.getline(7))[3])
+ local command_total_time = tonumber(n.fn.split(n.fn.getline(7))[2])
+ local command_self_time = tonumber(n.fn.split(n.fn.getline(7))[3])
- helpers.neq(nil, command_total_time)
- helpers.neq(nil, command_self_time)
+ t.neq(nil, command_total_time)
+ t.neq(nil, command_self_time)
end)
it('`yes` interrupted with CTRL-C', function()
@@ -262,14 +256,14 @@ describe('system()', function()
)
screen:expect([[
|
- ~ |*12
+ {1:~ }|*12
]] .. (is_os('win') and [[
:call system("for /L %I in (1,0,2) do @echo y") |]] or [[
:call system("yes") |]]))
feed('foo<c-c>')
screen:expect([[
^ |
- ~ |*12
+ {1:~ }|*12
Type :qa and press <Enter> to exit Nvim |
]])
end)
@@ -283,15 +277,15 @@ describe('system()', function()
)
screen:expect([[
|
- ~ |*12
+ {1:~ }|*12
]] .. (is_os('win') and [[
:call system("for /L %I in (1,0,2) do @echo y") |]] or [[
:call system("yes") |]]))
feed('foo<c-c>')
screen:expect([[
^ |
- ~ |*12
- -- INSERT -- |
+ {1:~ }|*12
+ {5:-- INSERT --} |
]])
end)
end)
@@ -447,7 +441,7 @@ describe('systemlist()', function()
feed(':call systemlist("echo")<cr>')
screen:expect([[
^ |
- ~ |*12
+ {1:~ }|*12
:call systemlist("echo") |
]])
end)
@@ -456,13 +450,13 @@ describe('systemlist()', function()
feed(':call systemlist("yes | xargs")<cr>')
screen:expect([[
|
- ~ |*12
+ {1:~ }|*12
:call systemlist("yes | xargs") |
]])
feed('<c-c>')
screen:expect([[
^ |
- ~ |*12
+ {1:~ }|*12
Type :qa and press <Enter> to exit Nvim |
]])
end)
@@ -554,11 +548,11 @@ describe('systemlist()', function()
end)
it('powershell w/ UTF-8 text #13713', function()
- if not helpers.has_powershell() then
+ if not n.has_powershell() then
pending('powershell not found', function() end)
return
end
- helpers.set_shell_powershell()
+ n.set_shell_powershell()
eq({ is_os('win') and 'あ\r' or 'あ' }, eval([[systemlist('Write-Output あ')]]))
-- Sanity test w/ default encoding
-- * on Windows, expected to default to Western European enc
@@ -574,7 +568,7 @@ describe('shell :!', function()
it(':{range}! with powershell filter/redirect #16271 #19250', function()
local screen = Screen.new(500, 8)
screen:attach()
- local found = helpers.set_shell_powershell(true)
+ local found = n.set_shell_powershell(true)
insert([[
3
1
@@ -621,12 +615,12 @@ describe('shell :!', function()
}
end
feed('<CR>')
- helpers.set_shell_powershell(true)
+ n.set_shell_powershell(true)
feed(':4verbose %w !sort<cr>')
screen:expect {
any = [[Executing command: .?& { Get%-Content .* | & sort }]],
}
feed('<CR>')
- helpers.expect_exit(command, 'qall!')
+ n.expect_exit(command, 'qall!')
end)
end)