aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ex_cmds/write_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/ex_cmds/write_spec.lua')
-rw-r--r--test/functional/ex_cmds/write_spec.lua46
1 files changed, 38 insertions, 8 deletions
diff --git a/test/functional/ex_cmds/write_spec.lua b/test/functional/ex_cmds/write_spec.lua
index 32fe397c03..1ccd27875e 100644
--- a/test/functional/ex_cmds/write_spec.lua
+++ b/test/functional/ex_cmds/write_spec.lua
@@ -8,7 +8,9 @@ local command = helpers.command
local feed_command = helpers.feed_command
local funcs = helpers.funcs
local meths = helpers.meths
-local iswin = helpers.iswin
+local skip = helpers.skip
+local is_os = helpers.is_os
+local is_ci = helpers.is_ci
local fname = 'Xtest-functional-ex_cmds-write'
local fname_bak = fname .. '~'
@@ -19,6 +21,9 @@ describe(':write', function()
os.remove('test_bkc_file.txt')
os.remove('test_bkc_link.txt')
os.remove('test_fifo')
+ os.remove('test/write/p_opt.txt')
+ os.remove('test/write')
+ os.remove('test')
os.remove(fname)
os.remove(fname_bak)
os.remove(fname_broken)
@@ -34,7 +39,7 @@ describe(':write', function()
it('&backupcopy=auto preserves symlinks', function()
command('set backupcopy=auto')
write_file('test_bkc_file.txt', 'content0')
- if iswin() then
+ if is_os('win') then
command("silent !mklink test_bkc_link.txt test_bkc_file.txt")
else
command("silent !ln -s test_bkc_file.txt test_bkc_link.txt")
@@ -52,9 +57,10 @@ describe(':write', function()
end)
it('&backupcopy=no replaces symlink with new file', function()
+ skip(is_ci('cirrus'))
command('set backupcopy=no')
write_file('test_bkc_file.txt', 'content0')
- if iswin() then
+ if is_os('win') then
command("silent !mklink test_bkc_link.txt test_bkc_file.txt")
else
command("silent !ln -s test_bkc_file.txt test_bkc_link.txt")
@@ -73,7 +79,7 @@ describe(':write', function()
it("appends FIFO file", function()
-- mkfifo creates read-only .lnk files on Windows
- if iswin() or eval("executable('mkfifo')") == 0 then
+ if is_os('win') or eval("executable('mkfifo')") == 0 then
pending('missing "mkfifo" command')
end
@@ -90,11 +96,36 @@ describe(':write', function()
fifo:close()
end)
+ it("++p creates missing parent directories", function()
+ eq(0, eval("filereadable('p_opt.txt')"))
+ command("write ++p p_opt.txt")
+ eq(1, eval("filereadable('p_opt.txt')"))
+ os.remove("p_opt.txt")
+
+ eq(0, eval("filereadable('p_opt.txt')"))
+ command("write ++p ./p_opt.txt")
+ eq(1, eval("filereadable('p_opt.txt')"))
+ os.remove("p_opt.txt")
+
+ eq(0, eval("filereadable('test/write/p_opt.txt')"))
+ command("write ++p test/write/p_opt.txt")
+ eq(1, eval("filereadable('test/write/p_opt.txt')"))
+
+ eq(('Vim(write):E32: No file name'), pcall_err(command, 'write ++p test_write/'))
+ if not is_os('win') then
+ eq(('Vim(write):E17: "'..funcs.fnamemodify('.', ':p:h')..'" is a directory'),
+ pcall_err(command, 'write ++p .'))
+ eq(('Vim(write):E17: "'..funcs.fnamemodify('.', ':p:h')..'" is a directory'),
+ pcall_err(command, 'write ++p ./'))
+ end
+ end)
+
it('errors out correctly', function()
+ skip(is_ci('cirrus'))
command('let $HOME=""')
eq(funcs.fnamemodify('.', ':p:h'), funcs.fnamemodify('.', ':p:h:~'))
-- Message from check_overwrite
- if not iswin() then
+ if not is_os('win') then
eq(('Vim(write):E17: "'..funcs.fnamemodify('.', ':p:h')..'" is a directory'),
pcall_err(command, 'write .'))
end
@@ -113,7 +144,7 @@ describe(':write', function()
funcs.setfperm(fname, 'r--------')
eq('Vim(write):E505: "Xtest-functional-ex_cmds-write" is read-only (add ! to override)',
pcall_err(command, 'write'))
- if iswin() then
+ if is_os('win') then
eq(0, os.execute('del /q/f ' .. fname))
eq(0, os.execute('rd /q/s ' .. fname_bak))
else
@@ -121,8 +152,7 @@ describe(':write', function()
eq(true, os.remove(fname_bak))
end
write_file(fname_bak, 'TTYX')
- -- FIXME: exc_exec('write!') outputs 0 in Windows
- if iswin() then return end
+ skip(is_os('win'), [[FIXME: exc_exec('write!') outputs 0 in Windows]])
lfs.link(fname_bak .. ('/xxxxx'):rep(20), fname, true)
eq('Vim(write):E166: Can\'t open linked file for writing',
pcall_err(command, 'write!'))