diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2024-09-02 15:52:18 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-02 15:52:18 -0700 |
| commit | ae9674704ac5586438f60c883e918d448ef0e237 (patch) | |
| tree | b621a6b44c8f95b3db18274b4e6d0f319cdbd391 /test/testutil.lua | |
| parent | ef8067a19d981388a14407ea08245811cf5b3604 (diff) | |
| parent | 96128a5076b7e45fc01163151401a9e2acdff565 (diff) | |
| download | rneovim-ae9674704ac5586438f60c883e918d448ef0e237.tar.gz rneovim-ae9674704ac5586438f60c883e918d448ef0e237.tar.bz2 rneovim-ae9674704ac5586438f60c883e918d448ef0e237.zip | |
Merge #30237 validate --listen address
Diffstat (limited to 'test/testutil.lua')
| -rw-r--r-- | test/testutil.lua | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/test/testutil.lua b/test/testutil.lua index 439f13cf49..0118f6b9e9 100644 --- a/test/testutil.lua +++ b/test/testutil.lua @@ -402,14 +402,18 @@ end local tmpname_id = 0 local tmpdir = tmpdir_get() ---- Creates a new temporary file for use by tests. -function M.tmpname() +--- Generates a unique file path for use by tests, and writes the file unless `create=false`. +--- +---@param create? boolean (default true) Write the file. +function M.tmpname(create) if tmpdir_is_local(tmpdir) then -- Cannot control os.tmpname() dir, so hack our own tmpname() impl. tmpname_id = tmpname_id + 1 -- "…/Xtest_tmpdir/T42.7" local fname = ('%s/%s.%d'):format(tmpdir, (_G._nvim_test_id or 'nvim-test'), tmpname_id) - io.open(fname, 'w'):close() + if create ~= false then + io.open(fname, 'w'):close() + end return fname end |