summaryrefslogtreecommitdiff
path: root/src/testdir/test_swap.vim
diff options
context:
space:
mode:
Diffstat (limited to 'src/testdir/test_swap.vim')
-rw-r--r--src/testdir/test_swap.vim45
1 files changed, 15 insertions, 30 deletions
diff --git a/src/testdir/test_swap.vim b/src/testdir/test_swap.vim
index a46494003..5237edcfb 100644
--- a/src/testdir/test_swap.vim
+++ b/src/testdir/test_swap.vim
@@ -16,7 +16,7 @@ func Test_swap_directory()
\ 'line 2 Abcdefghij',
\ 'line 3 Abcdefghij',
\ 'end of testfile']
- call writefile(content, 'Xtest1')
+ call writefile(content, 'Xtest1', 'D')
" '.', swap file in the same directory as file
set dir=.,~
@@ -30,7 +30,7 @@ func Test_swap_directory()
" './dir', swap file in a directory relative to the file
set dir=./Xtest2,.,~
- call mkdir("Xtest2")
+ call mkdir("Xtest2", 'R')
edit Xtest1
call assert_equal([], glob(swfname, 1, 1, 1))
let swfname = "Xtest2/Xtest1.swp"
@@ -40,7 +40,7 @@ func Test_swap_directory()
" 'dir', swap file in directory relative to the current dir
set dir=Xtest.je,~
- call mkdir("Xtest.je")
+ call mkdir("Xtest.je", 'R')
call writefile(content, 'Xtest2/Xtest3')
edit Xtest2/Xtest3
call assert_equal(["Xtest2/Xtest3"], glob("Xtest2/*", 1, 1, 1))
@@ -49,9 +49,6 @@ func Test_swap_directory()
call assert_equal([swfname], glob("Xtest.je/*", 1, 1, 1))
set dir&
- call delete("Xtest1")
- call delete("Xtest2", "rf")
- call delete("Xtest.je", "rf")
endfunc
func Test_swap_group()
@@ -135,7 +132,7 @@ func Test_swapinfo()
let info = swapinfo('doesnotexist')
call assert_equal('Cannot open file', info.error)
- call writefile(['burp'], 'Xnotaswapfile')
+ call writefile(['burp'], 'Xnotaswapfile', 'D')
let info = swapinfo('Xnotaswapfile')
call assert_equal('Cannot read file', info.error)
call delete('Xnotaswapfile')
@@ -143,7 +140,6 @@ func Test_swapinfo()
call writefile([repeat('x', 10000)], 'Xnotaswapfile')
let info = swapinfo('Xnotaswapfile')
call assert_equal('Not a swap file', info.error)
- call delete('Xnotaswapfile')
endfunc
func Test_swapname()
@@ -191,7 +187,7 @@ func Test_swapfile_delete()
" Close the file and recreate the swap file.
" Now editing the file will run into the process still existing
quit
- call writefile(swapfile_bytes, swapfile_name)
+ call writefile(swapfile_bytes, swapfile_name, 'D')
let s:swap_choice = 'e'
let s:swapname = ''
split XswapfileText
@@ -219,7 +215,6 @@ func Test_swapfile_delete()
call assert_equal(fnamemodify(swapfile_name, ':t'), fnamemodify(s:swapname, ':t'))
call delete('XswapfileText')
- call delete(swapfile_name)
augroup test_swapfile_delete
autocmd!
augroup END
@@ -233,7 +228,7 @@ func Test_swap_recover()
autocmd SwapExists * let v:swapchoice = 'r'
augroup END
- call mkdir('Xswap')
+ call mkdir('Xswap', 'R')
let $Xswap = 'foo' " Check for issue #4369.
set dir=Xswap//
" Create a valid swapfile by editing a file.
@@ -246,7 +241,7 @@ func Test_swap_recover()
" Close the file and recreate the swap file.
quit
- call writefile(swapfile_bytes, swapfile_name)
+ call writefile(swapfile_bytes, swapfile_name, 'D')
" Edit the file again. This triggers recovery.
try
split Xswap/text
@@ -258,9 +253,6 @@ func Test_swap_recover()
call assert_equal(['one', 'two', 'three'], getline(1, 3))
quit!
- call delete('Xswap/text')
- call delete(swapfile_name)
- call delete('Xswap', 'd')
unlet $Xswap
set dir&
augroup test_swap_recover
@@ -288,7 +280,7 @@ func Test_swap_recover_ext()
" Close and delete the file and recreate the swap file.
quit
call delete('Xtest.scr')
- call writefile(swapfile_bytes, swapfile_name)
+ call writefile(swapfile_bytes, swapfile_name, 'D')
" Edit the file again. This triggers recovery.
try
split Xtest.scr
@@ -301,7 +293,6 @@ func Test_swap_recover_ext()
quit!
call delete('Xtest.scr')
- call delete(swapfile_name)
augroup test_swap_recover_ext
autocmd!
augroup END
@@ -329,7 +320,7 @@ func Test_swap_split_win()
" Close and delete the file and recreate the swap file.
quit
call delete('Xtest.scr')
- call writefile(swapfile_bytes, swapfile_name)
+ call writefile(swapfile_bytes, swapfile_name, 'D')
" Split edit the file again. This should fail to open the window
try
split Xtest.scr
@@ -340,7 +331,6 @@ func Test_swap_split_win()
call assert_equal(1, winnr('$'))
call delete('Xtest.scr')
- call delete(swapfile_name)
augroup test_swap_splitwin
autocmd!
@@ -352,7 +342,7 @@ endfunc
func Test_swap_prompt_splitwin()
CheckRunVimInTerminal
- call writefile(['foo bar'], 'Xfile1')
+ call writefile(['foo bar'], 'Xfile1', 'D')
edit Xfile1
preserve " should help to make sure the swap file exists
@@ -387,13 +377,12 @@ func Test_swap_prompt_splitwin()
call StopVimInTerminal(buf)
%bwipe!
- call delete('Xfile1')
endfunc
func Test_swap_symlink()
CheckUnix
- call writefile(['text'], 'Xtestfile')
+ call writefile(['text'], 'Xtestfile', 'D')
silent !ln -s -f Xtestfile Xtestlink
set dir=.
@@ -404,7 +393,7 @@ func Test_swap_symlink()
call assert_match('Xtestfile\.swp$', s:swapname())
bwipe!
- call mkdir('Xswapdir')
+ call mkdir('Xswapdir', 'R')
exe 'set dir=' . getcwd() . '/Xswapdir//'
" Check that this also works when 'directory' ends with '//'
@@ -413,9 +402,7 @@ func Test_swap_symlink()
bwipe!
set dir&
- call delete('Xtestfile')
call delete('Xtestlink')
- call delete('Xswapdir', 'rf')
endfunc
func s:get_unused_pid(base)
@@ -467,7 +454,7 @@ func Test_swap_auto_delete()
" Change the process ID to avoid the "still running" warning.
let swapfile_bytes[24:27] = s:pid_to_blob(s:get_unused_pid(
\ s:blob_to_pid(swapfile_bytes[24:27])))
- call writefile(swapfile_bytes, swapfile_name)
+ call writefile(swapfile_bytes, swapfile_name, 'D')
edit Xtest.scr
" will end up using the same swap file after deleting the existing one
call assert_equal(swapfile_name, swapname('%'))
@@ -491,7 +478,6 @@ func Test_swap_auto_delete()
bwipe!
call delete('Xtest.scr')
- call delete(swapfile_name)
augroup test_swap_recover_ext
autocmd!
augroup END
@@ -520,13 +506,13 @@ endfunc
" Test for the v:swapchoice variable
func Test_swapchoice()
- call writefile(['aaa', 'bbb'], 'Xfile5')
+ call writefile(['aaa', 'bbb'], 'Xfile5', 'D')
edit Xfile5
preserve
let swapfname = swapname('')
let b = readblob(swapfname)
bw!
- call writefile(b, swapfname)
+ call writefile(b, swapfname, 'D')
autocmd! SwapExists
@@ -565,7 +551,6 @@ func Test_swapchoice()
%bw!
call assert_false(filereadable(swapfname))
- call delete('Xfile5')
call delete(swapfname)
augroup test_swapchoice
autocmd!