comparison src/testdir/test_swap.vim @ 25133:e0baf334f1ca v8.2.3103

patch 8.2.3103: swap test may fail on some systems Commit: https://github.com/vim/vim/commit/f33cae605064c8bdb908a8069d936f752572cd76 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 4 17:36:54 2021 +0200 patch 8.2.3103: swap test may fail on some systems Problem: Swap test may fail on some systems when jobs take longer to exit. Solution: Use different file names.
author Bram Moolenaar <Bram@vim.org>
date Sun, 04 Jul 2021 17:45:03 +0200
parents ba16f025f2e2
children da0e5ff44b14
comparison
equal deleted inserted replaced
25132:aeb096819289 25133:e0baf334f1ca
500 endfunc 500 endfunc
501 501
502 " Test for renaming a buffer when the swap file is deleted out-of-band 502 " Test for renaming a buffer when the swap file is deleted out-of-band
503 func Test_missing_swap_file() 503 func Test_missing_swap_file()
504 CheckUnix 504 CheckUnix
505 new Xfile1 505 new Xfile2
506 call delete(swapname('')) 506 call delete(swapname(''))
507 call assert_fails('file Xfile2', 'E301:') 507 call assert_fails('file Xfile3', 'E301:')
508 call assert_equal('Xfile2', bufname()) 508 call assert_equal('Xfile3', bufname())
509 call assert_true(bufexists('Xfile1'))
510 call assert_true(bufexists('Xfile2')) 509 call assert_true(bufexists('Xfile2'))
510 call assert_true(bufexists('Xfile3'))
511 %bw! 511 %bw!
512 endfunc 512 endfunc
513 513
514 " Test for :preserve command 514 " Test for :preserve command
515 func Test_preserve() 515 func Test_preserve()
516 new Xfile1 516 new Xfile4
517 setlocal noswapfile 517 setlocal noswapfile
518 call assert_fails('preserve', 'E313:') 518 call assert_fails('preserve', 'E313:')
519 bw! 519 bw!
520 endfunc 520 endfunc
521 521
522 " Test for the v:swapchoice variable 522 " Test for the v:swapchoice variable
523 func Test_swapchoice() 523 func Test_swapchoice()
524 call writefile(['aaa', 'bbb'], 'Xfile1') 524 call writefile(['aaa', 'bbb'], 'Xfile5')
525 edit Xfile1 525 edit Xfile5
526 preserve 526 preserve
527 let swapfname = swapname('') 527 let swapfname = swapname('')
528 let b = readblob(swapfname) 528 let b = readblob(swapfname)
529 bw! 529 bw!
530 call writefile(b, swapfname) 530 call writefile(b, swapfname)
534 " Test for v:swapchoice = 'o' (readonly) 534 " Test for v:swapchoice = 'o' (readonly)
535 augroup test_swapchoice 535 augroup test_swapchoice
536 autocmd! 536 autocmd!
537 autocmd SwapExists * let v:swapchoice = 'o' 537 autocmd SwapExists * let v:swapchoice = 'o'
538 augroup END 538 augroup END
539 edit Xfile1 539 edit Xfile5
540 call assert_true(&readonly) 540 call assert_true(&readonly)
541 call assert_equal(['aaa', 'bbb'], getline(1, '$')) 541 call assert_equal(['aaa', 'bbb'], getline(1, '$'))
542 %bw! 542 %bw!
543 call assert_true(filereadable(swapfname)) 543 call assert_true(filereadable(swapfname))
544 544
546 augroup test_swapchoice 546 augroup test_swapchoice
547 autocmd! 547 autocmd!
548 autocmd SwapExists * let v:swapchoice = 'a' 548 autocmd SwapExists * let v:swapchoice = 'a'
549 augroup END 549 augroup END
550 try 550 try
551 edit Xfile1 551 edit Xfile5
552 catch /^Vim:Interrupt$/ 552 catch /^Vim:Interrupt$/
553 endtry 553 endtry
554 call assert_equal('', @%) 554 call assert_equal('', @%)
555 call assert_true(bufexists('Xfile1')) 555 call assert_true(bufexists('Xfile5'))
556 %bw! 556 %bw!
557 call assert_true(filereadable(swapfname)) 557 call assert_true(filereadable(swapfname))
558 558
559 " Test for v:swapchoice = 'd' (delete) 559 " Test for v:swapchoice = 'd' (delete)
560 augroup test_swapchoice 560 augroup test_swapchoice
561 autocmd! 561 autocmd!
562 autocmd SwapExists * let v:swapchoice = 'd' 562 autocmd SwapExists * let v:swapchoice = 'd'
563 augroup END 563 augroup END
564 edit Xfile1 564 edit Xfile5
565 call assert_equal('Xfile1', @%) 565 call assert_equal('Xfile5', @%)
566 %bw! 566 %bw!
567 call assert_false(filereadable(swapfname)) 567 call assert_false(filereadable(swapfname))
568 568
569 call delete('Xfile1') 569 call delete('Xfile5')
570 call delete(swapfname) 570 call delete(swapfname)
571 augroup test_swapchoice 571 augroup test_swapchoice
572 autocmd! 572 autocmd!
573 augroup END 573 augroup END
574 augroup! test_swapchoice 574 augroup! test_swapchoice