From 499c9a15531b7a0e9736a395e8d401ceab3d24d2 Mon Sep 17 00:00:00 2001 From: George Zhao Date: Wed, 24 Jan 2018 18:01:14 +0800 Subject: [PATCH] test/win: fix some environment assumptions #7912 fix #7909 fix #7910 --- test/functional/core/job_spec.lua | 3 ++- test/functional/eval/hostname_spec.lua | 5 ++++- test/functional/helpers.lua | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index e957650c88..a02d36c939 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -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) diff --git a/test/functional/eval/hostname_spec.lua b/test/functional/eval/hostname_spec.lua index 6d5b64b929..6112cf64e3 100644 --- a/test/functional/eval/hostname_spec.lua +++ b/test/functional/eval/hostname_spec.lua @@ -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) diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index dfc4694272..f0e47481da 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -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,