test: Use workspace-local temp directory.

Closes #6291
This commit is contained in:
Justin M. Keyes 2017-03-29 20:07:39 +02:00
parent 1f478cebeb
commit 1ea9ebf112
4 changed files with 32 additions and 21 deletions

6
.gitignore vendored
View File

@ -39,9 +39,6 @@ tags
# generated by luacheck during `make testlint' # generated by luacheck during `make testlint'
/test/.luacheckcache /test/.luacheckcache
# luarocks, not added as a subtree because of the large number of blobs
/third-party/luarocks
# local make targets # local make targets
local.mk local.mk
@ -49,6 +46,3 @@ local.mk
/runtime/doc/*.html /runtime/doc/*.html
/runtime/doc/tags.ref /runtime/doc/tags.ref
/runtime/doc/errors.log /runtime/doc/errors.log
# clint errors, generated by `make lint`
/errors.json

View File

@ -25,6 +25,8 @@ if(DEFINED ENV{TEST_FILTER})
set(TEST_TAG "--filter=$ENV{TEST_FILTER}") set(TEST_TAG "--filter=$ENV{TEST_FILTER}")
endif() endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${WORKING_DIR}/Xtest-tmpdir)
set(ENV{TMPDIR} ${WORKING_DIR}/Xtest-tmpdir)
set(ENV{SYSTEM_NAME} ${SYSTEM_NAME}) set(ENV{SYSTEM_NAME} ${SYSTEM_NAME})
execute_process( execute_process(
COMMAND ${BUSTED_PRG} ${TEST_TAG} ${TEST_FILTER} -v -o ${BUSTED_OUTPUT_TYPE} COMMAND ${BUSTED_PRG} ${TEST_TAG} ${TEST_FILTER} -v -o ${BUSTED_OUTPUT_TYPE}
@ -37,6 +39,7 @@ execute_process(
file(REMOVE ${WORKING_DIR}/Xtest_rplugin_manifest) file(REMOVE ${WORKING_DIR}/Xtest_rplugin_manifest)
file(REMOVE_RECURSE ${WORKING_DIR}/Xtest_xdg) file(REMOVE_RECURSE ${WORKING_DIR}/Xtest_xdg)
file(REMOVE_RECURSE ${WORKING_DIR}/Xtest-tmpdir)
if(NOT res EQUAL 0) if(NOT res EQUAL 0)
message(STATUS "Output to stderr:\n${err}") message(STATUS "Output to stderr:\n${err}")

View File

@ -8,6 +8,7 @@ local clear, eq, eval, exc_exec, execute, feed, insert, neq, next_msg, nvim,
local command = helpers.command local command = helpers.command
local wait = helpers.wait local wait = helpers.wait
local iswin = helpers.iswin local iswin = helpers.iswin
local get_pathsep = helpers.get_pathsep
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
describe('jobs', function() describe('jobs', function()
@ -65,7 +66,7 @@ describe('jobs', function()
end) end)
it('changes to given `cwd` directory', function() it('changes to given `cwd` directory', function()
local dir = eval('resolve(tempname())') local dir = eval("resolve(tempname())"):gsub("/", get_pathsep())
mkdir(dir) mkdir(dir)
nvim('command', "let g:job_opts.cwd = '" .. dir .. "'") nvim('command', "let g:job_opts.cwd = '" .. dir .. "'")
if iswin() then if iswin() then

View File

@ -106,20 +106,33 @@ local uname = (function()
end) end)
end)() end)()
local function tmpname() local tmpname = (function()
local fname = os.tmpname() local seq = 0
if uname() == 'Windows' and fname:sub(1, 2) == '\\s' then local tmpdir = os.getenv('TMPDIR') and os.getenv('TMPDIR') or os.getenv('TEMP')
-- In Windows tmpname() returns a filename starting with -- Is $TMPDIR defined local to the project workspace?
-- special sequence \s, prepend $TEMP path local in_workspace = not not (tmpdir and string.find(tmpdir, 'Xtest'))
local tmpdir = os.getenv('TEMP') return (function()
return tmpdir..fname if in_workspace then
elseif fname:match('^/tmp') and uname() == 'Darwin' then -- Cannot control os.tmpname() dir, so hack our own tmpname() impl.
-- In OS X /tmp links to /private/tmp seq = seq + 1
return '/private'..fname local fname = tmpdir..'/nvim-test-lua-'..seq
else io.open(fname, 'w'):close()
return fname return fname
end else
end local fname = os.tmpname()
if uname() == 'Windows' and fname:sub(1, 2) == '\\s' then
-- In Windows tmpname() returns a filename starting with
-- special sequence \s, prepend $TEMP path
return tmpdir..fname
elseif fname:match('^/tmp') and uname() == 'Darwin' then
-- In OS X /tmp links to /private/tmp
return '/private'..fname
else
return fname
end
end
end)
end)()
local function map(func, tab) local function map(func, tab)
local rettab = {} local rettab = {}