test/win: fix some environment assumptions #7912

fix #7909
fix #7910
This commit is contained in:
George Zhao 2018-01-24 18:01:14 +08:00 committed by Justin M. Keyes
parent 16a6f44570
commit 499c9a1553
3 changed files with 12 additions and 2 deletions

View File

@ -9,6 +9,7 @@ local command = helpers.command
local wait = helpers.wait
local iswin = helpers.iswin
local get_pathsep = helpers.get_pathsep
local pathroot = helpers.pathroot
local nvim_set = helpers.nvim_set
local expect_twostreams = helpers.expect_twostreams
local Screen = require('test.functional.ui.screen')
@ -63,7 +64,7 @@ describe('jobs', function()
nvim('command', "let j = jobstart('pwd', g:job_opts)")
end
eq({'notification', 'stdout',
{0, {(iswin() and [[C:\]] or '/'), ''}}}, next_msg())
{0, {pathroot(), ''}}}, next_msg())
eq({'notification', 'stdout', {0, {''}}}, next_msg())
eq({'notification', 'exit', {0, 0}}, next_msg())
end)

View File

@ -1,7 +1,9 @@
local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq
local ok = helpers.ok
local call = helpers.call
local clear = helpers.clear
local iswin = helpers.iswin
describe('hostname()', function()
before_each(clear)
@ -11,7 +13,8 @@ describe('hostname()', function()
ok(string.len(actual) > 0)
if call('executable', 'hostname') == 1 then
local expected = string.gsub(call('system', 'hostname'), '[\n\r]', '')
helpers.eq(expected, actual)
eq((iswin() and expected:upper() or expected),
(iswin() and actual:upper() or actual))
end
end)
end)

View File

@ -603,6 +603,11 @@ local function get_pathsep()
return funcs.fnamemodify('.', ':p'):sub(-1)
end
local function pathroot()
local pathsep = package.config:sub(1,1)
return iswin() and (nvim_dir:sub(1,2)..pathsep) or '/'
end
-- Returns a valid, platform-independent $NVIM_LISTEN_ADDRESS.
-- Useful for communicating with child instances.
local function new_pipename()
@ -736,6 +741,7 @@ local module = {
meth_pcall = meth_pcall,
NIL = mpack.NIL,
get_pathsep = get_pathsep,
pathroot = pathroot,
missing_provider = missing_provider,
alter_slashes = alter_slashes,
hexdump = hexdump,