comparison src/testdir/test_excmd.vim @ 24572:dcb3a856f515 v8.2.2825

patch 8.2.2825: code in checkreadonly() not fully tested Commit: https://github.com/vim/vim/commit/2bf6034e5caf36b319148f46ba9a12e36c3bd41d Author: Dominique Pelle <dominique.pelle@gmail.com> Date: Sun May 2 20:16:24 2021 +0200 patch 8.2.2825: code in checkreadonly() not fully tested Problem: Code in checkreadonly() not fully tested. Solution: Add more tests. (Dominique Pell?, closes https://github.com/vim/vim/issues/8169)
author Bram Moolenaar <Bram@vim.org>
date Sun, 02 May 2021 20:30:04 +0200
parents 09598e5ced97
children acd9220bdd0b
comparison
equal deleted inserted replaced
24571:227e254b71b7 24572:dcb3a856f515
315 \ term_getline(buf, 20))}, 1000) 315 \ term_getline(buf, 20))}, 1000)
316 call StopVimInTerminal(buf) 316 call StopVimInTerminal(buf)
317 317
318 call delete('Xscript') 318 call delete('Xscript')
319 call delete('Xfoo') 319 call delete('Xfoo')
320 endfunc
321
322 func Test_confirm_write_ro()
323 CheckNotGui
324 CheckRunVimInTerminal
325
326 call writefile(['foo'], 'Xconfirm_write_ro')
327 let lines =<< trim END
328 set nobackup ff=unix cmdheight=2
329 edit Xconfirm_write_ro
330 norm Abar
331 END
332 call writefile(lines, 'Xscript')
333 let buf = RunVimInTerminal('-S Xscript', {'rows': 20})
334
335 " Try to write with 'ro' option.
336 call term_sendkeys(buf, ":set ro | confirm w\n")
337 call WaitForAssert({-> assert_match("^'readonly' option is set for \"Xconfirm_write_ro\"\. *$",
338 \ term_getline(buf, 18))}, 1000)
339 call WaitForAssert({-> assert_match('^Do you wish to write anyway? *$',
340 \ term_getline(buf, 19))}, 1000)
341 call WaitForAssert({-> assert_match('^(Y)es, \[N\]o: *$', term_getline(buf, 20))}, 1000)
342 call term_sendkeys(buf, 'N')
343 call WaitForAssert({-> assert_match('^ *$', term_getline(buf, 19))}, 1000)
344 call WaitForAssert({-> assert_match('.* All$', term_getline(buf, 20))}, 1000)
345 call assert_equal(['foo'], readfile('Xconfirm_write_ro'))
346
347 call term_sendkeys(buf, ":confirm w\n")
348 call WaitForAssert({-> assert_match("^'readonly' option is set for \"Xconfirm_write_ro\"\. *$",
349 \ term_getline(buf, 18))}, 1000)
350 call WaitForAssert({-> assert_match('^Do you wish to write anyway? *$',
351 \ term_getline(buf, 19))}, 1000)
352 call WaitForAssert({-> assert_match('^(Y)es, \[N\]o: *$', term_getline(buf, 20))}, 1000)
353 call term_sendkeys(buf, 'Y')
354 call WaitForAssert({-> assert_match('^"Xconfirm_write_ro" 1L, 7B written$',
355 \ term_getline(buf, 19))}, 1000)
356 call assert_equal(['foobar'], readfile('Xconfirm_write_ro'))
357
358 " Try to write with read-only file permissions.
359 call setfperm('Xconfirm_write_ro', 'r--r--r--')
360 call term_sendkeys(buf, ":set noro | undo | confirm w\n")
361 call WaitForAssert({-> assert_match("^File permissions of \"Xconfirm_write_ro\" are read-only\. *$",
362 \ term_getline(buf, 17))}, 1000)
363 call WaitForAssert({-> assert_match('^It may still be possible to write it\. *$',
364 \ term_getline(buf, 18))}, 1000)
365 call WaitForAssert({-> assert_match('^Do you wish to try? *$', term_getline(buf, 19))}, 1000)
366 call WaitForAssert({-> assert_match('^(Y)es, \[N\]o: *$', term_getline(buf, 20))}, 1000)
367 call term_sendkeys(buf, 'Y')
368 call WaitForAssert({-> assert_match('^"Xconfirm_write_ro" 1L, 4B written$',
369 \ term_getline(buf, 19))}, 1000)
370 call assert_equal(['foo'], readfile('Xconfirm_write_ro'))
371
372 call StopVimInTerminal(buf)
373 call delete('Xscript')
374 call delete('Xconfirm_write_ro')
320 endfunc 375 endfunc
321 376
322 " Test for the :print command 377 " Test for the :print command
323 func Test_print_cmd() 378 func Test_print_cmd()
324 call assert_fails('print', 'E749:') 379 call assert_fails('print', 'E749:')