aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/test_writefile.vim
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-05-09 17:08:21 -0400
committerGitHub <noreply@github.com>2021-05-09 17:08:21 -0400
commitd2be261e8d1bcf165346255ae701564a5f62bf7d (patch)
tree470c5fb8f4e57098295e87f0df318f729569dd83 /src/nvim/testdir/test_writefile.vim
parentf8173df4d7ecec239629921736340d3f4d1dcfd4 (diff)
parenteef5a627bfc4341fdd6f12ea5932d11b12fbf2c0 (diff)
downloadrneovim-d2be261e8d1bcf165346255ae701564a5f62bf7d.tar.gz
rneovim-d2be261e8d1bcf165346255ae701564a5f62bf7d.tar.bz2
rneovim-d2be261e8d1bcf165346255ae701564a5f62bf7d.zip
Merge pull request #14403 from seandewar/vim-8.2.1933
vim-patch:8.2.{0174,1933,1935,1946,2286,2287}
Diffstat (limited to 'src/nvim/testdir/test_writefile.vim')
-rw-r--r--src/nvim/testdir/test_writefile.vim63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_writefile.vim b/src/nvim/testdir/test_writefile.vim
index c62c01d5f3..c7710ff198 100644
--- a/src/nvim/testdir/test_writefile.vim
+++ b/src/nvim/testdir/test_writefile.vim
@@ -164,6 +164,69 @@ func Test_writefile_autowrite_nowrite()
set noautowrite
endfunc
+" Test for ':w !<cmd>' to pipe lines from the current buffer to an external
+" command.
+func Test_write_pipe_to_cmd()
+ if !has('unix')
+ return
+ endif
+ new
+ call setline(1, ['L1', 'L2', 'L3', 'L4'])
+ 2,3w !cat > Xfile
+ call assert_equal(['L2', 'L3'], readfile('Xfile'))
+ close!
+ call delete('Xfile')
+endfunc
+
+" Test for :saveas
+func Test_saveas()
+ call assert_fails('saveas', 'E471:')
+ call writefile(['L1'], 'Xfile')
+ new Xfile
+ new
+ call setline(1, ['L1'])
+ call assert_fails('saveas Xfile', 'E139:')
+ close!
+ enew | only
+ call delete('Xfile')
+endfunc
+
+func Test_write_errors()
+ " Test for writing partial buffer
+ call writefile(['L1', 'L2', 'L3'], 'Xfile')
+ new Xfile
+ call assert_fails('1,2write', 'E140:')
+ close!
+
+ " Try to overwrite a directory
+ if has('unix')
+ call mkdir('Xdir1')
+ call assert_fails('write Xdir1', 'E17:')
+ call delete('Xdir1', 'd')
+ endif
+
+ " Test for :wall for a buffer with no name
+ enew | only
+ call setline(1, ['L1'])
+ call assert_fails('wall', 'E141:')
+ enew!
+
+ " Test for writing a 'readonly' file
+ new Xfile
+ set readonly
+ call assert_fails('write', 'E45:')
+ close
+
+ " Test for writing to a read-only file
+ new Xfile
+ call setfperm('Xfile', 'r--r--r--')
+ call assert_fails('write', 'E505:')
+ call setfperm('Xfile', 'rw-rw-rw-')
+ close
+
+ call delete('Xfile')
+endfunc
+
func Test_writefile_sync_dev_stdout()
if !has('unix')
return