diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2024-09-03 02:18:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-03 02:18:17 -0700 |
commit | ea2d9493514a82bb5077e73957a22648cb5d7d14 (patch) | |
tree | ad7254108729759fe2e27746179c212d0a58089a /test/testutil.lua | |
parent | ae9674704ac5586438f60c883e918d448ef0e237 (diff) | |
download | rneovim-ea2d9493514a82bb5077e73957a22648cb5d7d14.tar.gz rneovim-ea2d9493514a82bb5077e73957a22648cb5d7d14.tar.bz2 rneovim-ea2d9493514a82bb5077e73957a22648cb5d7d14.zip |
test: tmpname(create:boolean) #30242
Problem:
137f98cf6428 added the `create` parameter to `tmpname()` but didn't
fully implement it.
Solution:
- Update impl for the `os.tmpname()` codepath.
- Inspect all usages of `tmpname()`, update various tests.
Diffstat (limited to 'test/testutil.lua')
-rw-r--r-- | test/testutil.lua | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/test/testutil.lua b/test/testutil.lua index 0118f6b9e9..01eaf25406 100644 --- a/test/testutil.lua +++ b/test/testutil.lua @@ -402,7 +402,8 @@ end local tmpname_id = 0 local tmpdir = tmpdir_get() ---- Generates a unique file path for use by tests, and writes the file unless `create=false`. +--- Generates a unique filepath for use by tests, in a test-specific "…/Xtest_tmpdir/T42.7" +--- directory (which is cleaned up by the test runner), and writes the file unless `create=false`. --- ---@param create? boolean (default true) Write the file. function M.tmpname(create) @@ -418,6 +419,10 @@ function M.tmpname(create) end local fname = os.tmpname() + if create == false then + os.remove(fname) + end + if M.is_os('win') and fname:sub(1, 2) == '\\s' then -- In Windows tmpname() returns a filename starting with -- special sequence \s, prepend $TEMP path |