aboutsummaryrefslogtreecommitdiff
path: root/test/functional/vimscript/writefile_spec.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-01-14 23:13:48 -0700
committerJosh Rahm <joshuarahm@gmail.com>2023-01-14 23:13:48 -0700
commit7a6e249a32f79331bfb5e29bc0cabcf89a026081 (patch)
tree27a7354ec18448e4090ac91581534baa7b537254 /test/functional/vimscript/writefile_spec.lua
parent442d4e54c30b8e193e3f6e4d32b43e96815bccd7 (diff)
parent6134c1e8a39a5e61d0593613343a5923a86e3545 (diff)
downloadrneovim-7a6e249a32f79331bfb5e29bc0cabcf89a026081.tar.gz
rneovim-7a6e249a32f79331bfb5e29bc0cabcf89a026081.tar.bz2
rneovim-7a6e249a32f79331bfb5e29bc0cabcf89a026081.zip
Merge remote-tracking branch 'upstream/master' into usermarks
Diffstat (limited to 'test/functional/vimscript/writefile_spec.lua')
-rw-r--r--test/functional/vimscript/writefile_spec.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/functional/vimscript/writefile_spec.lua b/test/functional/vimscript/writefile_spec.lua
index 5f693249a9..8c8da9dc88 100644
--- a/test/functional/vimscript/writefile_spec.lua
+++ b/test/functional/vimscript/writefile_spec.lua
@@ -111,6 +111,26 @@ describe('writefile()', function()
pcall_err(command, ('call writefile([42], %s)'):format(ddname_tail)))
end)
+ it('writefile(..., "p") creates missing parent directories', function()
+ os.remove(dname)
+ eq(nil, read_file(dfname))
+ eq(0, funcs.writefile({'abc', 'def', 'ghi'}, dfname, 'p'))
+ eq('abc\ndef\nghi\n', read_file(dfname))
+ os.remove(dfname)
+ os.remove(dname)
+ eq(nil, read_file(dfname))
+ eq(0, funcs.writefile({'\na\nb\n'}, dfname, 'pb'))
+ eq('\0a\0b\0', read_file(dfname))
+ os.remove(dfname)
+ os.remove(dname)
+ eq('Vim(call):E32: No file name',
+ pcall_err(command, ('call writefile([], "%s", "p")'):format(dfname .. '.d/')))
+ eq(('Vim(call):E482: Can\'t open file ./ for writing: illegal operation on a directory'),
+ pcall_err(command, 'call writefile([], "./", "p")'))
+ eq(('Vim(call):E482: Can\'t open file . for writing: illegal operation on a directory'),
+ pcall_err(command, 'call writefile([], ".", "p")'))
+ end)
+
it('errors out with invalid arguments', function()
write_file(fname, 'TEST')
eq('Vim(call):E119: Not enough arguments for function: writefile',