aboutsummaryrefslogtreecommitdiff
path: root/test/functional/core/main_spec.lua
diff options
context:
space:
mode:
authorRafael Kitover <rkitover@gmail.com>2024-06-18 03:23:52 +0000
committerGitHub <noreply@github.com>2024-06-18 11:23:52 +0800
commit1a1c766049826b6049610edda8f72eac1f75b38d (patch)
tree6230039ff3e8325b6def86624e4ff198e77e2059 /test/functional/core/main_spec.lua
parent948f2beed4ea55a9c2cce3cff894359b94fba748 (diff)
downloadrneovim-1a1c766049826b6049610edda8f72eac1f75b38d.tar.gz
rneovim-1a1c766049826b6049610edda8f72eac1f75b38d.tar.bz2
rneovim-1a1c766049826b6049610edda8f72eac1f75b38d.zip
refactor: Windows tilde expansion followup (#29380)
Followup to #28515: Rename the static os_homedir() to os_uv_homedir() to emphasize that it is a wrapper around a libuv function. Add the function os_get_homedir() to os/env.c to return the cached homedir value as a const. Must be called after homedir is initialized or it fails. The difference between this function and the static os_uv_homedir() is that the latter gets the homedir from libuv and is used to initialize homedir in init_homedir(), while os_get_homedir() just returns homedir as a const if it's initialized and is public. Use the os_get_homedir() accessor for ~/ expansion on Windows to make the code more concise. Add a Windows section to main_spec.lua with tests for expanding ~/ and ~\ prefixes for files passed in on the command-line. Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Diffstat (limited to 'test/functional/core/main_spec.lua')
-rw-r--r--test/functional/core/main_spec.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/functional/core/main_spec.lua b/test/functional/core/main_spec.lua
index 5e903726db..a6e917b4b2 100644
--- a/test/functional/core/main_spec.lua
+++ b/test/functional/core/main_spec.lua
@@ -193,4 +193,26 @@ describe('command-line option', function()
matches('Run "nvim %-V1 %-v"', fn.system({ nvim_prog_abs(), '-v' }))
matches('Compilation: .*Run :checkhealth', fn.system({ nvim_prog_abs(), '-V1', '-v' }))
end)
+
+ if is_os('win') then
+ for _, prefix in ipairs({ '~/', '~\\' }) do
+ it('expands ' .. prefix .. ' on Windows', function()
+ local fname = os.getenv('USERPROFILE') .. '\\nvim_test.txt'
+ finally(function()
+ os.remove(fname)
+ end)
+ write_file(fname, 'some text')
+ eq(
+ 'some text',
+ fn.system({
+ nvim_prog_abs(),
+ '-es',
+ '+%print',
+ '+q',
+ prefix .. 'nvim_test.txt',
+ }):gsub('\n', '')
+ )
+ end)
+ end
+ end
end)