diff options
author | kylo252 <59826753+kylo252@users.noreply.github.com> | 2023-07-16 14:50:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-16 05:50:10 -0700 |
commit | f660b794808ac809ee8cafe82ddd824840bc8e2c (patch) | |
tree | 4e43accfbb4b60414caa99e03cdec54203d676cf /test/functional/lua/watch_spec.lua | |
parent | c3de6524a53dc355b1c8074eb6940e9e73714057 (diff) | |
download | rneovim-f660b794808ac809ee8cafe82ddd824840bc8e2c.tar.gz rneovim-f660b794808ac809ee8cafe82ddd824840bc8e2c.tar.bz2 rneovim-f660b794808ac809ee8cafe82ddd824840bc8e2c.zip |
test(fs): get tmpdir robustly #23021
Problem:
helpers.tmpname() may create a local file, depending on circumstances.
Solution:
Only use helpers.tmpname() for its parent directory (the "temp root").
Use fs_mkdtemp() to actually get a unique name.
Diffstat (limited to 'test/functional/lua/watch_spec.lua')
-rw-r--r-- | test/functional/lua/watch_spec.lua | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/test/functional/lua/watch_spec.lua b/test/functional/lua/watch_spec.lua index f041f4f1b6..d802a955fa 100644 --- a/test/functional/lua/watch_spec.lua +++ b/test/functional/lua/watch_spec.lua @@ -3,7 +3,6 @@ local eq = helpers.eq local exec_lua = helpers.exec_lua local clear = helpers.clear local is_os = helpers.is_os -local mkdir = helpers.mkdir describe('vim._watch', function() before_each(function() @@ -12,9 +11,7 @@ describe('vim._watch', function() describe('watch', function() it('detects file changes', function() - local root_dir = helpers.tmpname() - os.remove(root_dir) - mkdir(root_dir) + local root_dir = vim.loop.fs_mkdtemp(vim.fs.dirname(helpers.tmpname()) .. '/nvim_XXXXXXXXXX') local result = exec_lua( [[ @@ -100,9 +97,7 @@ describe('vim._watch', function() describe('poll', function() it('detects file changes', function() - local root_dir = helpers.tmpname() - os.remove(root_dir) - mkdir(root_dir) + local root_dir = vim.loop.fs_mkdtemp(vim.fs.dirname(helpers.tmpname()) .. '/nvim_XXXXXXXXXX') local result = exec_lua( [[ |