aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/test_excmd.vim
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-05-06 09:00:24 -0400
committerGitHub <noreply@github.com>2021-05-06 09:00:24 -0400
commit71107e12c7b68d8faf1bcc1a5794a55b21e146f3 (patch)
tree57623fc268dbf5d2a919f04aa3d66c78bff78cb4 /src/nvim/testdir/test_excmd.vim
parent8a93d1028f38c77d7ad8b4ad0a93dc11a5cbe85d (diff)
parent296711cfad7bb8d80f2e2c363b3708764156444f (diff)
downloadrneovim-71107e12c7b68d8faf1bcc1a5794a55b21e146f3.tar.gz
rneovim-71107e12c7b68d8faf1bcc1a5794a55b21e146f3.tar.bz2
rneovim-71107e12c7b68d8faf1bcc1a5794a55b21e146f3.zip
Merge pull request #14499 from janlazo/vim-8.2.2819
vim-patch:8.0.1309,8.2.{1166,2819,2820,2825,2827,2828,2829,2832,2833}
Diffstat (limited to 'src/nvim/testdir/test_excmd.vim')
-rw-r--r--src/nvim/testdir/test_excmd.vim55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_excmd.vim b/src/nvim/testdir/test_excmd.vim
index 15557056ee..4c7452fe69 100644
--- a/src/nvim/testdir/test_excmd.vim
+++ b/src/nvim/testdir/test_excmd.vim
@@ -132,6 +132,61 @@ func Test_confirm_cmd_cancel()
call StopVimInTerminal(buf)
endfunc
+func Test_confirm_write_ro()
+ CheckNotGui
+ CheckRunVimInTerminal
+
+ call writefile(['foo'], 'Xconfirm_write_ro')
+ let lines =<< trim END
+ set nobackup ff=unix cmdheight=2
+ edit Xconfirm_write_ro
+ norm Abar
+ END
+ call writefile(lines, 'Xscript')
+ let buf = RunVimInTerminal('-S Xscript', {'rows': 20})
+
+ " Try to write with 'ro' option.
+ call term_sendkeys(buf, ":set ro | confirm w\n")
+ call WaitForAssert({-> assert_match("^'readonly' option is set for \"Xconfirm_write_ro\"\. *$",
+ \ term_getline(buf, 18))}, 1000)
+ call WaitForAssert({-> assert_match('^Do you wish to write anyway? *$',
+ \ term_getline(buf, 19))}, 1000)
+ call WaitForAssert({-> assert_match('^(Y)es, \[N\]o: *$', term_getline(buf, 20))}, 1000)
+ call term_sendkeys(buf, 'N')
+ call WaitForAssert({-> assert_match('^ *$', term_getline(buf, 19))}, 1000)
+ call WaitForAssert({-> assert_match('.* All$', term_getline(buf, 20))}, 1000)
+ call assert_equal(['foo'], readfile('Xconfirm_write_ro'))
+
+ call term_sendkeys(buf, ":confirm w\n")
+ call WaitForAssert({-> assert_match("^'readonly' option is set for \"Xconfirm_write_ro\"\. *$",
+ \ term_getline(buf, 18))}, 1000)
+ call WaitForAssert({-> assert_match('^Do you wish to write anyway? *$',
+ \ term_getline(buf, 19))}, 1000)
+ call WaitForAssert({-> assert_match('^(Y)es, \[N\]o: *$', term_getline(buf, 20))}, 1000)
+ call term_sendkeys(buf, 'Y')
+ call WaitForAssert({-> assert_match('^"Xconfirm_write_ro" 1L, 7B written$',
+ \ term_getline(buf, 19))}, 1000)
+ call assert_equal(['foobar'], readfile('Xconfirm_write_ro'))
+
+ " Try to write with read-only file permissions.
+ call setfperm('Xconfirm_write_ro', 'r--r--r--')
+ call term_sendkeys(buf, ":set noro | undo | confirm w\n")
+ call WaitForAssert({-> assert_match("^File permissions of \"Xconfirm_write_ro\" are read-only\. *$",
+ \ term_getline(buf, 17))}, 1000)
+ call WaitForAssert({-> assert_match('^It may still be possible to write it\. *$',
+ \ term_getline(buf, 18))}, 1000)
+ call WaitForAssert({-> assert_match('^Do you wish to try? *$', term_getline(buf, 19))}, 1000)
+ call WaitForAssert({-> assert_match('^(Y)es, \[N\]o: *$', term_getline(buf, 20))}, 1000)
+ call term_sendkeys(buf, 'Y')
+ call WaitForAssert({-> assert_match('^"Xconfirm_write_ro" 1L, 4B written$',
+ \ term_getline(buf, 19))}, 1000)
+ call assert_equal(['foo'], readfile('Xconfirm_write_ro'))
+
+ call StopVimInTerminal(buf)
+ call delete('Xscript')
+ call delete('Xconfirm_write_ro')
+endfunc
+
" Test for the :winsize command
func Test_winsize_cmd()
call assert_fails('winsize 1', 'E465:')