aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-03-29 20:07:39 +0200
committerJustin M. Keyes <justinkz@gmail.com>2017-03-30 02:55:00 +0200
commit1ea9ebf112d6c9d6355038afb4aaee794187cb23 (patch)
treecec418a7bae041575d91b8eabbc0f3b1926b8a56 /test
parent1f478cebeb929332e90c1b50de4b8a4f311a0df2 (diff)
downloadrneovim-1ea9ebf112d6c9d6355038afb4aaee794187cb23.tar.gz
rneovim-1ea9ebf112d6c9d6355038afb4aaee794187cb23.tar.bz2
rneovim-1ea9ebf112d6c9d6355038afb4aaee794187cb23.zip
test: Use workspace-local temp directory.
Closes #6291
Diffstat (limited to 'test')
-rw-r--r--test/functional/core/job_spec.lua3
-rw-r--r--test/helpers.lua41
2 files changed, 29 insertions, 15 deletions
diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua
index e442c2a317..9ee91f2fe9 100644
--- a/test/functional/core/job_spec.lua
+++ b/test/functional/core/job_spec.lua
@@ -8,6 +8,7 @@ local clear, eq, eval, exc_exec, execute, feed, insert, neq, next_msg, nvim,
local command = helpers.command
local wait = helpers.wait
local iswin = helpers.iswin
+local get_pathsep = helpers.get_pathsep
local Screen = require('test.functional.ui.screen')
describe('jobs', function()
@@ -65,7 +66,7 @@ describe('jobs', function()
end)
it('changes to given `cwd` directory', function()
- local dir = eval('resolve(tempname())')
+ local dir = eval("resolve(tempname())"):gsub("/", get_pathsep())
mkdir(dir)
nvim('command', "let g:job_opts.cwd = '" .. dir .. "'")
if iswin() then
diff --git a/test/helpers.lua b/test/helpers.lua
index 1a86effa1c..82451bc61d 100644
--- a/test/helpers.lua
+++ b/test/helpers.lua
@@ -106,20 +106,33 @@ local uname = (function()
end)
end)()
-local function tmpname()
- 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
- local tmpdir = os.getenv('TEMP')
- 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
+local tmpname = (function()
+ local seq = 0
+ local tmpdir = os.getenv('TMPDIR') and os.getenv('TMPDIR') or os.getenv('TEMP')
+ -- Is $TMPDIR defined local to the project workspace?
+ local in_workspace = not not (tmpdir and string.find(tmpdir, 'Xtest'))
+ return (function()
+ if in_workspace then
+ -- Cannot control os.tmpname() dir, so hack our own tmpname() impl.
+ seq = seq + 1
+ local fname = tmpdir..'/nvim-test-lua-'..seq
+ io.open(fname, 'w'):close()
+ return fname
+ else
+ 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 rettab = {}