summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominique Pelle <dominique.pelle@gmail.com>2021-05-02 20:16:24 +0200
committerBram Moolenaar <Bram@vim.org>2021-05-02 20:16:24 +0200
commit2bf6034e5caf36b319148f46ba9a12e36c3bd41d (patch)
tree59c18e41b78206410a3583f80df89601b4e0c0da
parent1bb0da25a6581cd09d6df91f11ce866dc775597b (diff)
patch 8.2.2825: code in checkreadonly() not fully testedv8.2.2825
Problem: Code in checkreadonly() not fully tested. Solution: Add more tests. (Dominique Pellé, closes #8169)
-rw-r--r--src/testdir/test_excmd.vim55
-rw-r--r--src/version.c2
2 files changed, 57 insertions, 0 deletions
diff --git a/src/testdir/test_excmd.vim b/src/testdir/test_excmd.vim
index 8aace51cb4..f830be8a4a 100644
--- a/src/testdir/test_excmd.vim
+++ b/src/testdir/test_excmd.vim
@@ -319,6 +319,61 @@ func Test_confirm_q_wq()
call delete('Xfoo')
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 :print command
func Test_print_cmd()
call assert_fails('print', 'E749:')
diff --git a/src/version.c b/src/version.c
index 435117dacb..a72cd3c05e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2825,
+/**/
2824,
/**/
2823,