comparison src/testdir/test_writefile.vim @ 21897:e0af4660dfc7 v8.2.1498

patch 8.2.1498: on slow systems tests can be flaky Commit: https://github.com/vim/vim/commit/733d259a83bfdd3e1670cc1665e1bd56501799df Author: Bram Moolenaar <Bram@vim.org> Date: Thu Aug 20 18:59:06 2020 +0200 patch 8.2.1498: on slow systems tests can be flaky Problem: On slow systems tests can be flaky. Solution: Use TermWait() instead of term-wait(). (Yegappan Lakshmanan, closes #6756)
author Bram Moolenaar <Bram@vim.org>
date Thu, 20 Aug 2020 19:00:03 +0200
parents 08940efa6b4e
children ff21e2962490
comparison
equal deleted inserted replaced
21896:4f7b50471a6a 21897:e0af4660dfc7
266 266
267 " First read the file into a buffer 267 " First read the file into a buffer
268 call writefile(["Line1", "Line2"], 'Xfile') 268 call writefile(["Line1", "Line2"], 'Xfile')
269 let old_ftime = getftime('Xfile') 269 let old_ftime = getftime('Xfile')
270 let buf = RunVimInTerminal('Xfile', #{rows : 10}) 270 let buf = RunVimInTerminal('Xfile', #{rows : 10})
271 call term_wait(buf) 271 call TermWait(buf)
272 call term_sendkeys(buf, ":set noswapfile\<CR>") 272 call term_sendkeys(buf, ":set noswapfile\<CR>")
273 call term_wait(buf) 273 call TermWait(buf)
274 274
275 " Modify the file directly. Make sure the file modification time is 275 " Modify the file directly. Make sure the file modification time is
276 " different. Note that on Linux/Unix, the file is considered modified 276 " different. Note that on Linux/Unix, the file is considered modified
277 " outside, only if the difference is 2 seconds or more 277 " outside, only if the difference is 2 seconds or more
278 sleep 1 278 sleep 1
284 let new_ftime = getftime('Xfile') 284 let new_ftime = getftime('Xfile')
285 endwhile 285 endwhile
286 286
287 " Try to overwrite the file and check for the prompt 287 " Try to overwrite the file and check for the prompt
288 call term_sendkeys(buf, ":w\<CR>") 288 call term_sendkeys(buf, ":w\<CR>")
289 call term_wait(buf) 289 call TermWait(buf)
290 call WaitForAssert({-> assert_equal("WARNING: The file has been changed since reading it!!!", term_getline(buf, 9))}) 290 call WaitForAssert({-> assert_equal("WARNING: The file has been changed since reading it!!!", term_getline(buf, 9))})
291 call assert_equal("Do you really want to write to it (y/n)?", 291 call assert_equal("Do you really want to write to it (y/n)?",
292 \ term_getline(buf, 10)) 292 \ term_getline(buf, 10))
293 call term_sendkeys(buf, "n\<CR>") 293 call term_sendkeys(buf, "n\<CR>")
294 call term_wait(buf) 294 call TermWait(buf)
295 call assert_equal(new_ftime, getftime('Xfile')) 295 call assert_equal(new_ftime, getftime('Xfile'))
296 call term_sendkeys(buf, ":w\<CR>") 296 call term_sendkeys(buf, ":w\<CR>")
297 call term_wait(buf) 297 call TermWait(buf)
298 call term_sendkeys(buf, "y\<CR>") 298 call term_sendkeys(buf, "y\<CR>")
299 call term_wait(buf) 299 call TermWait(buf)
300 call WaitForAssert({-> assert_equal('Line2', readfile('Xfile')[1])}) 300 call WaitForAssert({-> assert_equal('Line2', readfile('Xfile')[1])})
301 301
302 " clean up 302 " clean up
303 call StopVimInTerminal(buf) 303 call StopVimInTerminal(buf)
304 call delete('Xfile') 304 call delete('Xfile')
669 call assert_equal([utf32le_bom .. "u\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\nl\n\n\ne\n\n\n", "\n\n\n"], readfile('Xtest3', 'b')) 669 call assert_equal([utf32le_bom .. "u\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\nl\n\n\ne\n\n\n", "\n\n\n"], readfile('Xtest3', 'b'))
670 670
671 set cpoptions-=S 671 set cpoptions-=S
672 let &fileencoding = save_fileencoding 672 let &fileencoding = save_fileencoding
673 call delete('Xtest1') 673 call delete('Xtest1')
674 call delete('Xtest2') 674 call delete('Xfile2')
675 call delete('Xtest3') 675 call delete('Xtest3')
676 %bw! 676 %bw!
677 endfunc 677 endfunc
678 678
679 " vim: shiftwidth=2 sts=2 expandtab 679 " vim: shiftwidth=2 sts=2 expandtab