mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
test/functional: Fix api/vim_spec.lua.
On Windows the default file format is DOS i.e. newlines are \r\n instead of \n.
This commit is contained in:
parent
04cd3eef24
commit
a48508de0d
@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers')
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
local clear, nvim, eq, neq = helpers.clear, helpers.nvim, helpers.eq, helpers.neq
|
||||
local ok, nvim_async, feed = helpers.ok, helpers.nvim_async, helpers.feed
|
||||
|
||||
local os_is_windows = helpers.os_is_windows
|
||||
|
||||
describe('vim_* functions', function()
|
||||
before_each(clear)
|
||||
@ -17,7 +17,11 @@ describe('vim_* functions', function()
|
||||
nvim('command', 'w')
|
||||
local f = io.open(fname)
|
||||
ok(f ~= nil)
|
||||
eq('testing\napi\n', f:read('*a'))
|
||||
if os_is_windows() then
|
||||
eq('testing\r\napi\r\n', f:read('*a'))
|
||||
else
|
||||
eq('testing\napi\n', f:read('*a'))
|
||||
end
|
||||
f:close()
|
||||
os.remove(fname)
|
||||
end)
|
||||
|
@ -323,6 +323,10 @@ local function expect(contents)
|
||||
return eq(dedent(contents), curbuf_contents())
|
||||
end
|
||||
|
||||
local function os_is_windows()
|
||||
return nvim_eval('has("win32")') == 1
|
||||
end
|
||||
|
||||
local function rmdir(path)
|
||||
if lfs.attributes(path, 'mode') ~= 'directory' then
|
||||
return nil
|
||||
@ -425,6 +429,7 @@ return {
|
||||
wait = wait,
|
||||
set_session = set_session,
|
||||
write_file = write_file,
|
||||
os_is_windows = os_is_windows,
|
||||
rmdir = rmdir,
|
||||
mkdir = lfs.mkdir,
|
||||
exc_exec = exc_exec,
|
||||
|
@ -1,7 +1,8 @@
|
||||
|
||||
local helpers = require('test.functional.helpers')
|
||||
local nvim, eq, neq, eval = helpers.nvim, helpers.eq, helpers.neq, helpers.eval
|
||||
local clear = helpers.clear
|
||||
local clear, funcs, meths = helpers.clear, helpers.funcs, helpers.meths
|
||||
local os_is_windows = helpers.os_is_windows
|
||||
|
||||
describe('serverstart(), serverstop()', function()
|
||||
before_each(clear)
|
||||
@ -17,34 +18,32 @@ describe('serverstart(), serverstop()', function()
|
||||
eq('', eval('$NVIM_LISTEN_ADDRESS'))
|
||||
end)
|
||||
|
||||
it([[sets v:servername _only_ on nvim startup
|
||||
(unless all servers are stopped)]], function()
|
||||
local initial_server = eval('v:servername')
|
||||
it('sets v:servername _only_ on nvim startup unless all servers are stopped',
|
||||
function()
|
||||
local initial_server = meths.get_vvar('servername')
|
||||
assert(initial_server ~= nil and initial_server:len() > 0,
|
||||
"v:servername was not initialized")
|
||||
'v:servername was not initialized')
|
||||
|
||||
-- v:servername is readonly so we cannot unset it--but we can test that it
|
||||
-- does not get set again thereafter.
|
||||
local s = eval('serverstart()')
|
||||
local s = funcs.serverstart()
|
||||
assert(s ~= nil and s:len() > 0, "serverstart() returned empty")
|
||||
neq(initial_server, s)
|
||||
|
||||
-- serverstop() does _not_ modify v:servername...
|
||||
nvim('command', "call serverstop('"..s.."')")
|
||||
eq(initial_server, eval('v:servername'))
|
||||
funcs.serverstop(s)
|
||||
eq(initial_server, meths.get_vvar('servername'))
|
||||
|
||||
-- ...unless we stop _all_ servers.
|
||||
nvim('command', "call serverstop(serverlist()[0])")
|
||||
eq('', eval('v:servername'))
|
||||
funcs.serverstop(funcs.serverlist()[1])
|
||||
eq('', meths.get_vvar('servername'))
|
||||
|
||||
-- v:servername will take the next available server.
|
||||
if eval('has("win32")') then
|
||||
nvim('command', "call serverstart('\\\\.\\pipe\\test_server_pipe')")
|
||||
eq('\\\\.\\pipe\\test_server_pipe', eval('v:servername'))
|
||||
else
|
||||
nvim('command', "call serverstart('test_server_socket')")
|
||||
eq('test_server_socket', eval('v:servername'))
|
||||
end
|
||||
local servername = (os_is_windows()
|
||||
and [[\\.\pipe\Xtest-functional-server-server-pipe]]
|
||||
or 'Xtest-functional-server-server-socket')
|
||||
funcs.serverstart(servername)
|
||||
eq(servername, meths.get_vvar('servername'))
|
||||
end)
|
||||
|
||||
it('serverstop() ignores invalid input', function()
|
||||
|
Loading…
Reference in New Issue
Block a user