vim-patch:9.0.0336: tests are flaky because of using a common file name

Problem:    Tests are flaky because of using a common file name.
Solution:   Rename files and directories to be more unique.

61abe7d8f8

Cherry-pick Test_custom_complete_autoload() from patch 8.2.4584.
Cherry-pick test_delete.vim & test_edit.vim changes from patch 9.0.0323.
Cherry-pick test_edit.vim changes from patch 8.2.3637.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2023-11-13 09:08:02 +08:00
parent 5c69f8569a
commit b9cffe40fa
10 changed files with 205 additions and 183 deletions

View File

@ -2447,7 +2447,7 @@ function Test_dirchanged_auto()
set acd
cd ..
call assert_equal([], s:li)
exe 'edit ' . s:dir_foo . '/Xfile'
exe 'edit ' . s:dir_foo . '/Xautofile'
call assert_equal(s:dir_foo, getcwd())
let expected = ["pre cd " .. s:dir_foo, "auto:", s:dir_foo]
call assert_equal(expected, s:li)
@ -3124,7 +3124,7 @@ func Test_FileChangedRO_winclose()
augroup FileChangedROTest
au!
autocmd FileChangedRO * edit Xfile
autocmd FileChangedRO * edit Xrofile
augroup END
new
set readonly
@ -3200,13 +3200,13 @@ endfunc
" Test for passing invalid arguments to autocmd
func Test_autocmd_invalid_args()
" Additional character after * for event
call assert_fails('autocmd *a Xfile set ff=unix', 'E215:')
call assert_fails('autocmd *a Xinvfile set ff=unix', 'E215:')
augroup Test
augroup END
" Invalid autocmd event
call assert_fails('autocmd Bufabc Xfile set ft=vim', 'E216:')
call assert_fails('autocmd Bufabc Xinvfile set ft=vim', 'E216:')
" Invalid autocmd event in a autocmd group
call assert_fails('autocmd Test Bufabc Xfile set ft=vim', 'E216:')
call assert_fails('autocmd Test Bufabc Xinvfile set ft=vim', 'E216:')
augroup! Test
" Execute all autocmds
call assert_fails('doautocmd * BufEnter', 'E217:')
@ -3217,9 +3217,9 @@ endfunc
" Test for deep nesting of autocmds
func Test_autocmd_deep_nesting()
autocmd BufEnter Xfile doautocmd BufEnter Xfile
call assert_fails('doautocmd BufEnter Xfile', 'E218:')
autocmd! BufEnter Xfile
autocmd BufEnter Xdeepfile doautocmd BufEnter Xdeepfile
call assert_fails('doautocmd BufEnter Xdeepfile', 'E218:')
autocmd! BufEnter Xdeepfile
endfunc
" Tests for SigUSR1 autocmd event, which is only available on posix systems.

View File

@ -134,7 +134,7 @@ func Test_bdelete_cmd()
call assert_fails('bdelete \)', 'E55:')
" Deleting a unlisted and unloaded buffer
edit Xfile1
edit Xbdelfile1
let bnr = bufnr()
set nobuflisted
enew
@ -310,8 +310,8 @@ endfunc
" Test for trying to load a buffer with text locked
" <C-\>e in the command line is used to lock the text
func Test_load_buf_with_text_locked()
new Xfile1
edit Xfile2
new Xlockfile1
edit Xlockfile2
let cmd = ":\<C-\>eexecute(\"normal \<C-O>\")\<CR>\<C-C>"
call assert_fails("call feedkeys(cmd, 'xt')", 'E565:')
%bw!

View File

@ -37,13 +37,13 @@ endfunc
" Tests for the getchangelist() function
func Test_changelist_index()
edit Xfile1.txt
edit Xgclfile1.txt
exe "normal iabc\<C-G>u\ndef\<C-G>u\nghi"
call assert_equal(3, getchangelist('%')[1])
" Move one step back in the changelist.
normal 2g;
hide edit Xfile2.txt
hide edit Xgclfile2.txt
exe "normal iabcd\<C-G>u\ndefg\<C-G>u\nghij"
call assert_equal(3, getchangelist('%')[1])
" Move to the beginning of the changelist.
@ -54,8 +54,8 @@ func Test_changelist_index()
call assert_equal(1, getchangelist('#')[1])
bwipe!
call delete('Xfile1.txt')
call delete('Xfile2.txt')
call delete('Xgclfile1.txt')
call delete('Xgclfile2.txt')
endfunc
func Test_getchangelist()
@ -64,10 +64,10 @@ func Test_getchangelist()
call assert_equal([], 10->getchangelist())
call assert_equal([[], 0], getchangelist())
call writefile(['line1', 'line2', 'line3'], 'Xfile1.txt')
call writefile(['line1', 'line2', 'line3'], 'Xfile2.txt')
call writefile(['line1', 'line2', 'line3'], 'Xclistfile1.txt')
call writefile(['line1', 'line2', 'line3'], 'Xclistfile2.txt')
edit Xfile1.txt
edit Xclistfile1.txt
let buf_1 = bufnr()
exe "normal 1Goline\<C-G>u1.1"
exe "normal 3Goline\<C-G>u2.1"
@ -79,7 +79,7 @@ func Test_getchangelist()
\ {'lnum' : 6, 'col' : 4, 'coladd' : 0}], 2],
\ getchangelist('%'))
hide edit Xfile2.txt
hide edit Xclistfile2.txt
let buf_2 = bufnr()
exe "normal 1GOline\<C-G>u1.0"
exe "normal 2Goline\<C-G>u2.0"
@ -100,8 +100,8 @@ func Test_getchangelist()
\ getchangelist(buf_2))
bwipe!
call delete('Xfile1.txt')
call delete('Xfile2.txt')
call delete('Xclistfile1.txt')
call delete('Xclistfile2.txt')
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@ -130,9 +130,9 @@ func Test_client_server()
" Run a separate instance to send a command to the server
call remote_expr(name, 'execute("only")')
call system(cmd .. ' --remote-send ":new Xfile<CR>"')
call system(cmd .. ' --remote-send ":new Xclientfile<CR>"')
call assert_equal('2', remote_expr(name, 'winnr("$")'))
call assert_equal('Xfile', remote_expr(name, 'winbufnr(1)->bufname()'))
call assert_equal('Xclientfile', remote_expr(name, 'winbufnr(1)->bufname()'))
call remote_expr(name, 'execute("only")')
" Invoke a remote-expr. On MS-Windows, the returned value has a carriage
@ -141,24 +141,24 @@ func Test_client_server()
call assert_equal(['4'], split(l, "\n"))
" Edit multiple files using --remote
call system(cmd .. ' --remote Xfile1 Xfile2 Xfile3')
call assert_match(".*Xfile1\n.*Xfile2\n.*Xfile3\n", remote_expr(name, 'argv()'))
call system(cmd .. ' --remote Xclientfile1 Xclientfile2 Xclientfile3')
call assert_match(".*Xclientfile1\n.*Xclientfile2\n.*Xclientfile3\n", remote_expr(name, 'argv()'))
eval name->remote_send(":%bw!\<CR>")
" Edit files in separate tab pages
call system(cmd .. ' --remote-tab Xfile1 Xfile2 Xfile3')
call system(cmd .. ' --remote-tab Xclientfile1 Xclientfile2 Xclientfile3')
call WaitForAssert({-> assert_equal('3', remote_expr(name, 'tabpagenr("$")'))})
call assert_match('.*\<Xfile2', remote_expr(name, 'bufname(tabpagebuflist(2)[0])'))
call assert_match('.*\<Xclientfile2', remote_expr(name, 'bufname(tabpagebuflist(2)[0])'))
eval name->remote_send(":%bw!\<CR>")
" Edit a file using --remote-wait
eval name->remote_send(":source $VIMRUNTIME/plugin/rrhelper.vim\<CR>")
call system(cmd .. ' --remote-wait +enew Xfile1')
call assert_match('.*\<Xfile1', remote_expr(name, 'bufname("#")'))
call system(cmd .. ' --remote-wait +enew Xclientfile1')
call assert_match('.*\<Xclientfile1', remote_expr(name, 'bufname("#")'))
eval name->remote_send(":%bw!\<CR>")
" Edit files using --remote-tab-wait
call system(cmd .. ' --remote-tabwait +tabonly\|enew Xfile1 Xfile2')
call system(cmd .. ' --remote-tabwait +tabonly\|enew Xclientfile1 Xclientfile2')
call assert_equal('1', remote_expr(name, 'tabpagenr("$")'))
eval name->remote_send(":%bw!\<CR>")

View File

@ -1126,14 +1126,14 @@ func Test_cmdline_complete_various()
call assert_equal("\"sI \<C-A>", @:)
" completion for :write command
call mkdir('Xdir')
call writefile(['one'], 'Xdir/Xfile1')
call mkdir('Xcwdir')
call writefile(['one'], 'Xcwdir/Xfile1')
let save_cwd = getcwd()
cd Xdir
cd Xcwdir
call feedkeys(":w >> \<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal("\"w >> Xfile1", @:)
call chdir(save_cwd)
call delete('Xdir', 'rf')
call delete('Xcwdir', 'rf')
" completion for :w ! and :r ! commands
call feedkeys(":w !invalid_xyz_cmd\<C-A>\<C-B>\"\<CR>", 'xt')
@ -1190,12 +1190,12 @@ func Test_cmdline_complete_various()
call assert_equal("\"doautocmd BufNew,BufEnter", @:)
" completion of file name in :doautocmd
call writefile([], 'Xfile1')
call writefile([], 'Xfile2')
call feedkeys(":doautocmd BufEnter Xfi\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal("\"doautocmd BufEnter Xfile1 Xfile2", @:)
call delete('Xfile1')
call delete('Xfile2')
call writefile([], 'Xvarfile1')
call writefile([], 'Xvarfile2')
call feedkeys(":doautocmd BufEnter Xvarfi\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal("\"doautocmd BufEnter Xvarfile1 Xvarfile2", @:)
call delete('Xvarfile1')
call delete('Xvarfile2')
" completion for the :augroup command
augroup XTest.test
@ -2010,17 +2010,17 @@ endfunc
" Test for using ~ for home directory in cmdline completion matches
func Test_cmdline_expand_home()
call mkdir('Xdir')
call writefile([], 'Xdir/Xfile1')
call writefile([], 'Xdir/Xfile2')
cd Xdir
call mkdir('Xexpdir')
call writefile([], 'Xexpdir/Xfile1')
call writefile([], 'Xexpdir/Xfile2')
cd Xexpdir
let save_HOME = $HOME
let $HOME = getcwd()
call feedkeys(":e ~/\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e ~/Xfile1 ~/Xfile2', @:)
let $HOME = save_HOME
cd ..
call delete('Xdir', 'rf')
call delete('Xexpdir', 'rf')
endfunc
" Test for using CTRL-\ CTRL-G in the command line to go back to normal mode
@ -2140,6 +2140,29 @@ func Test_wildmode()
let &encoding = save_encoding
endfunc
func Test_custom_complete_autoload()
call mkdir('Xcustdir/autoload', 'p')
let save_rtp = &rtp
exe 'set rtp=' .. getcwd() .. '/Xcustdir'
let lines =<< trim END
func vim8#Complete(a, c, p)
return "oneA\noneB\noneC"
endfunc
END
call writefile(lines, 'Xcustdir/autoload/vim8.vim')
command -nargs=1 -complete=custom,vim8#Complete MyCmd
set nowildmenu
set wildmode=full,list
call feedkeys(":MyCmd \<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"MyCmd oneA oneB oneC', @:)
let &rtp = save_rtp
set wildmode& wildmenu&
delcommand MyCmd
call delete('Xcustdir', 'rf')
endfunc
" Test for interrupting the command-line completion
func Test_interrupt_compl()
func F(lead, cmdl, p)
@ -2470,31 +2493,31 @@ endfunc
" Test for the 'suffixes' option
func Test_suffixes_opt()
call writefile([], 'Xfile')
call writefile([], 'Xfile.c')
call writefile([], 'Xfile.o')
call writefile([], 'Xsuffile')
call writefile([], 'Xsuffile.c')
call writefile([], 'Xsuffile.o')
set suffixes=
call feedkeys(":e Xfi*\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xfile Xfile.c Xfile.o', @:)
call feedkeys(":e Xfi*\<Tab>\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xfile.c', @:)
call feedkeys(":e Xsuffi*\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xsuffile Xsuffile.c Xsuffile.o', @:)
call feedkeys(":e Xsuffi*\<Tab>\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xsuffile.c', @:)
set suffixes=.c
call feedkeys(":e Xfi*\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xfile Xfile.o Xfile.c', @:)
call feedkeys(":e Xfi*\<Tab>\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xfile.o', @:)
call feedkeys(":e Xsuffi*\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xsuffile Xsuffile.o Xsuffile.c', @:)
call feedkeys(":e Xsuffi*\<Tab>\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xsuffile.o', @:)
set suffixes=,,
call feedkeys(":e Xfi*\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xfile.c Xfile.o Xfile', @:)
call feedkeys(":e Xfi*\<Tab>\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xfile.o', @:)
call feedkeys(":e Xsuffi*\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xsuffile.c Xsuffile.o Xsuffile', @:)
call feedkeys(":e Xsuffi*\<Tab>\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xsuffile.o', @:)
set suffixes&
" Test for getcompletion() with different patterns
call assert_equal(['Xfile', 'Xfile.c', 'Xfile.o'], getcompletion('Xfile', 'file'))
call assert_equal(['Xfile'], getcompletion('Xfile$', 'file'))
call delete('Xfile')
call delete('Xfile.c')
call delete('Xfile.o')
call assert_equal(['Xsuffile', 'Xsuffile.c', 'Xsuffile.o'], getcompletion('Xsuffile', 'file'))
call assert_equal(['Xsuffile'], getcompletion('Xsuffile$', 'file'))
call delete('Xsuffile')
call delete('Xsuffile.c')
call delete('Xsuffile.o')
endfunc
" Test for using a popup menu for the command line completion matches

View File

@ -31,17 +31,17 @@ func Test_cpo_A()
" Wipe out all the buffers, so that the alternate file is empty
edit Xfoo | %bw
set cpo-=A
new Xfile1
write Xfile2
new XcpoAfile1
write XcpoAfile2
call assert_equal('', @#)
%bw
call delete('Xfile2')
new Xfile1
call delete('XcpoAfile2')
new XcpoAfile1
set cpo+=A
write Xfile2
call assert_equal('Xfile2', @#)
write XcpoAfile2
call assert_equal('XcpoAfile2', @#)
close!
call delete('Xfile2')
call delete('XcpoAfile2')
let &cpo = save_cpo
endfunc

View File

@ -3,103 +3,103 @@
source check.vim
func Test_file_delete()
split Xfile
split Xfdelfile
call setline(1, ['a', 'b'])
wq
call assert_equal(['a', 'b'], readfile('Xfile'))
call assert_equal(0, delete('Xfile'))
call assert_fails('call readfile("Xfile")', 'E484:')
call assert_equal(-1, delete('Xfile'))
bwipe Xfile
call assert_equal(['a', 'b'], readfile('Xfdelfile'))
call assert_equal(0, delete('Xfdelfile'))
call assert_fails('call readfile("Xfdelfile")', 'E484:')
call assert_equal(-1, delete('Xfdelfile'))
bwipe Xfdelfile
endfunc
func Test_dir_delete()
call mkdir('Xdir1')
call assert_true(isdirectory('Xdir1'))
call assert_equal(0, delete('Xdir1', 'd'))
call assert_false(isdirectory('Xdir1'))
call assert_equal(-1, delete('Xdir1', 'd'))
call mkdir('Xdirdel')
call assert_true(isdirectory('Xdirdel'))
call assert_equal(0, delete('Xdirdel', 'd'))
call assert_false(isdirectory('Xdirdel'))
call assert_equal(-1, delete('Xdirdel', 'd'))
endfunc
func Test_recursive_delete()
call mkdir('Xdir1')
call mkdir('Xdir1/subdir')
call mkdir('Xdir1/empty')
split Xdir1/Xfile
call mkdir('Xrecdel')
call mkdir('Xrecdel/subdir')
call mkdir('Xrecdel/empty')
split Xrecdel/Xfile
call setline(1, ['a', 'b'])
w
w Xdir1/subdir/Xfile
w Xrecdel/subdir/Xfile
close
call assert_true(isdirectory('Xdir1'))
call assert_equal(['a', 'b'], readfile('Xdir1/Xfile'))
call assert_true(isdirectory('Xdir1/subdir'))
call assert_equal(['a', 'b'], readfile('Xdir1/subdir/Xfile'))
call assert_true('Xdir1/empty'->isdirectory())
call assert_equal(0, delete('Xdir1', 'rf'))
call assert_false(isdirectory('Xdir1'))
call assert_equal(-1, delete('Xdir1', 'd'))
bwipe Xdir1/Xfile
bwipe Xdir1/subdir/Xfile
call assert_true(isdirectory('Xrecdel'))
call assert_equal(['a', 'b'], readfile('Xrecdel/Xfile'))
call assert_true(isdirectory('Xrecdel/subdir'))
call assert_equal(['a', 'b'], readfile('Xrecdel/subdir/Xfile'))
call assert_true('Xrecdel/empty'->isdirectory())
call assert_equal(0, delete('Xrecdel', 'rf'))
call assert_false(isdirectory('Xrecdel'))
call assert_equal(-1, delete('Xrecdel', 'd'))
bwipe Xrecdel/Xfile
bwipe Xrecdel/subdir/Xfile
endfunc
func Test_symlink_delete()
CheckUnix
split Xfile
split Xslfile
call setline(1, ['a', 'b'])
wq
silent !ln -s Xfile Xlink
silent !ln -s Xslfile Xdellink
" Delete the link, not the file
call assert_equal(0, delete('Xlink'))
call assert_equal(-1, delete('Xlink'))
call assert_equal(0, delete('Xfile'))
bwipe Xfile
call assert_equal(0, delete('Xdellink'))
call assert_equal(-1, delete('Xdellink'))
call assert_equal(0, delete('Xslfile'))
bwipe Xslfile
endfunc
func Test_symlink_dir_delete()
CheckUnix
call mkdir('Xdir1')
silent !ln -s Xdir1 Xlink
call assert_true(isdirectory('Xdir1'))
call assert_true(isdirectory('Xlink'))
call mkdir('Xsymdir')
silent !ln -s Xsymdir Xdirlink
call assert_true(isdirectory('Xsymdir'))
call assert_true(isdirectory('Xdirlink'))
" Delete the link, not the directory
call assert_equal(0, delete('Xlink'))
call assert_equal(-1, delete('Xlink'))
call assert_equal(0, delete('Xdir1', 'd'))
call assert_equal(0, delete('Xdirlink'))
call assert_equal(-1, delete('Xdirlink'))
call assert_equal(0, delete('Xsymdir', 'd'))
endfunc
func Test_symlink_recursive_delete()
CheckUnix
call mkdir('Xdir3')
call mkdir('Xdir3/subdir')
call mkdir('Xdir4')
split Xdir3/Xfile
call mkdir('Xrecdir3')
call mkdir('Xrecdir3/subdir')
call mkdir('Xrecdir4')
split Xrecdir3/Xfile
call setline(1, ['a', 'b'])
w
w Xdir3/subdir/Xfile
w Xdir4/Xfile
w Xrecdir3/subdir/Xfile
w Xrecdir4/Xfile
close
silent !ln -s ../Xdir4 Xdir3/Xlink
silent !ln -s ../Xrecdir4 Xrecdir3/Xreclink
call assert_true(isdirectory('Xdir3'))
call assert_equal(['a', 'b'], readfile('Xdir3/Xfile'))
call assert_true(isdirectory('Xdir3/subdir'))
call assert_equal(['a', 'b'], readfile('Xdir3/subdir/Xfile'))
call assert_true(isdirectory('Xdir4'))
call assert_true(isdirectory('Xdir3/Xlink'))
call assert_equal(['a', 'b'], readfile('Xdir4/Xfile'))
call assert_true(isdirectory('Xrecdir3'))
call assert_equal(['a', 'b'], readfile('Xrecdir3/Xfile'))
call assert_true(isdirectory('Xrecdir3/subdir'))
call assert_equal(['a', 'b'], readfile('Xrecdir3/subdir/Xfile'))
call assert_true(isdirectory('Xrecdir4'))
call assert_true(isdirectory('Xrecdir3/Xreclink'))
call assert_equal(['a', 'b'], readfile('Xrecdir4/Xfile'))
call assert_equal(0, delete('Xdir3', 'rf'))
call assert_false(isdirectory('Xdir3'))
call assert_equal(-1, delete('Xdir3', 'd'))
call assert_equal(0, delete('Xrecdir3', 'rf'))
call assert_false(isdirectory('Xrecdir3'))
call assert_equal(-1, delete('Xrecdir3', 'd'))
" symlink is deleted, not the directory it points to
call assert_true(isdirectory('Xdir4'))
call assert_equal(['a', 'b'], readfile('Xdir4/Xfile'))
call assert_equal(0, delete('Xdir4/Xfile'))
call assert_equal(0, delete('Xdir4', 'd'))
call assert_true(isdirectory('Xrecdir4'))
call assert_equal(['a', 'b'], readfile('Xrecdir4/Xfile'))
call assert_equal(0, delete('Xrecdir4/Xfile'))
call assert_equal(0, delete('Xrecdir4', 'd'))
bwipe Xdir3/Xfile
bwipe Xdir3/subdir/Xfile
bwipe Xdir4/Xfile
bwipe Xrecdir3/Xfile
bwipe Xrecdir3/subdir/Xfile
bwipe Xrecdir4/Xfile
endfunc
func Test_delete_errors()

View File

@ -822,12 +822,13 @@ func Test_diff_lastline()
endfunc
func WriteDiffFiles(buf, list1, list2)
call writefile(a:list1, 'Xfile1')
call writefile(a:list2, 'Xfile2')
call writefile(a:list1, 'Xdifile1')
call writefile(a:list2, 'Xdifile2')
if a:buf
call term_sendkeys(a:buf, ":checktime\<CR>")
endif
endfunc
" Verify a screendump with both the internal and external diff.
func VerifyBoth(buf, dumpfile, extra)
" trailing : for leaving the cursor on the command line
@ -877,12 +878,12 @@ func Test_diff_screen()
call writefile(lines, 'XdiffSetup')
" clean up already existing swap files, just in case
call delete('.Xfile1.swp')
call delete('.Xfile2.swp')
call delete('.Xdifile1.swp')
call delete('.Xdifile2.swp')
" Test 1: Add a line in beginning of file 2
call WriteDiffFiles(0, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
let buf = RunVimInTerminal('-d -S XdiffSetup Xfile1 Xfile2', {})
let buf = RunVimInTerminal('-d -S XdiffSetup Xdifile1 Xdifile2', {})
" Set autoread mode, so that Vim won't complain once we re-write the test
" files
call term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w")
@ -1000,8 +1001,8 @@ func Test_diff_screen()
" clean up
call StopVimInTerminal(buf)
call delete('Xfile1')
call delete('Xfile2')
call delete('Xdifile1')
call delete('Xdifile2')
call delete('XdiffSetup')
endfunc
@ -1495,9 +1496,9 @@ endfunc
" for the issue fixed by patch 6.2.317)
func Test_diff_foldinvert()
%bw!
edit Xfile1
new Xfile2
new Xfile3
edit Xdoffile1
new Xdoffile2
new Xdoffile3
windo diffthis
" open a non-diff window
botright new

View File

@ -446,31 +446,31 @@ endfunc
" terminal.
func Test_autoindent_remove_indent()
CheckRunVimInTerminal
let buf = RunVimInTerminal('-N Xfile', {'rows': 6, 'cols' : 20})
let buf = RunVimInTerminal('-N Xarifile', {'rows': 6, 'cols' : 20})
call TermWait(buf)
call term_sendkeys(buf, ":set autoindent\n")
" leaving insert mode in a new line with indent added by autoindent, should
" remove the indent.
call term_sendkeys(buf, "i\<Tab>foo\<CR>\<Esc>")
" Need to delay for sometime, otherwise the code in getchar.c will not be
" Need to delay for some time, otherwise the code in getchar.c will not be
" exercised.
call TermWait(buf, 50)
" when a line is wrapped and the cursor is at the start of the second line,
" leaving insert mode, should move the cursor back to the first line.
call term_sendkeys(buf, "o" .. repeat('x', 20) .. "\<Esc>")
" Need to delay for sometime, otherwise the code in getchar.c will not be
" Need to delay for some time, otherwise the code in getchar.c will not be
" exercised.
call TermWait(buf, 50)
call term_sendkeys(buf, ":w\n")
call TermWait(buf)
call StopVimInTerminal(buf)
call assert_equal(["\tfoo", '', repeat('x', 20)], readfile('Xfile'))
call delete('Xfile')
call assert_equal(["\tfoo", '', repeat('x', 20)], readfile('Xarifile'))
call delete('Xarifile')
endfunc
func Test_edit_CR()
" Test for <CR> in insert mode
" basically only in quickfix mode ist tested, the rest
" basically only in quickfix mode it's tested, the rest
" has been taken care of by other tests
CheckFeature quickfix
botright new
@ -1518,12 +1518,10 @@ func Test_edit_rightleft()
endfunc
func Test_edit_complete_very_long_name()
if !has('unix')
" Long directory names only work on Unix.
return
endif
" Long directory names only work on Unix.
CheckUnix
let dirname = getcwd() . "/Xdir"
let dirname = getcwd() . "/Xlongdir"
let longdirname = dirname . repeat('/' . repeat('d', 255), 4)
try
call mkdir(longdirname, 'p')
@ -1561,7 +1559,7 @@ func Test_edit_complete_very_long_name()
let longfilename = longdirname . '/' . repeat('a', 255)
call writefile(['Totum', 'Table'], longfilename)
new
exe "next Xfile " . longfilename
exe "next Xnofile " . longfilename
exe "normal iT\<C-N>"
bwipe!
@ -1760,7 +1758,7 @@ endfunc
" Test for editing a directory
func Test_edit_is_a_directory()
CheckEnglish
let dirname = getcwd() . "/Xdir"
let dirname = getcwd() . "/Xeditdir"
call mkdir(dirname, 'p')
new
@ -1785,19 +1783,19 @@ endfunc
" Test for editing a file using invalid file encoding
func Test_edit_invalid_encoding()
CheckEnglish
call writefile([], 'Xfile')
call writefile([], 'Xinvfile')
redir => msg
new ++enc=axbyc Xfile
new ++enc=axbyc Xinvfile
redir END
call assert_match('\[NOT converted\]', msg)
call delete('Xfile')
call delete('Xinvfile')
close!
endfunc
" Test for the "charconvert" option
func Test_edit_charconvert()
CheckEnglish
call writefile(['one', 'two'], 'Xfile')
call writefile(['one', 'two'], 'Xccfile')
" set 'charconvert' to a non-existing function
set charconvert=NonExitingFunc()
@ -1805,7 +1803,7 @@ func Test_edit_charconvert()
let caught_e117 = v:false
try
redir => msg
edit ++enc=axbyc Xfile
edit ++enc=axbyc Xccfile
catch /E117:/
let caught_e117 = v:true
finally
@ -1823,7 +1821,7 @@ func Test_edit_charconvert()
set charconvert=Cconv1()
new
redir => msg
edit ++enc=axbyc Xfile
edit ++enc=axbyc Xccfile
redir END
call assert_equal(['one', 'two'], getline(1, '$'))
call assert_match("can't read output of 'charconvert'", msg)
@ -1838,10 +1836,10 @@ func Test_edit_charconvert()
call writefile(data, v:fname_out)
endfunc
set charconvert=Cconv2()
new Xfile
write ++enc=ucase Xfile1
call assert_equal(['ONE', 'TWO'], readfile('Xfile1'))
call delete('Xfile1')
new Xccfile
write ++enc=ucase Xccfile1
call assert_equal(['ONE', 'TWO'], readfile('Xccfile1'))
call delete('Xccfile1')
close!
delfunc Cconv2
set charconvert&
@ -1852,13 +1850,13 @@ func Test_edit_charconvert()
endfunc
set charconvert=Cconv3()
new
call assert_fails('edit ++enc=lcase Xfile', 'E202:')
call assert_fails('edit ++enc=lcase Xccfile', 'E202:')
call assert_equal([''], getline(1, '$'))
close!
delfunc Cconv3
set charconvert&
call delete('Xfile')
call delete('Xccfile')
endfunc
" Test for editing a file without read permission
@ -1866,17 +1864,17 @@ func Test_edit_file_no_read_perm()
CheckUnix
CheckNotRoot
call writefile(['one', 'two'], 'Xfile')
call setfperm('Xfile', '-w-------')
call writefile(['one', 'two'], 'Xnrpfile')
call setfperm('Xnrpfile', '-w-------')
new
redir => msg
edit Xfile
edit Xnrpfile
redir END
call assert_equal(1, &readonly)
call assert_equal([''], getline(1, '$'))
call assert_match('\[Permission Denied\]', msg)
close!
call delete('Xfile')
call delete('Xnrpfile')
endfunc
" Using :edit without leaving 'insertmode' should not cause Insert mode to be

View File

@ -185,14 +185,14 @@ let s:langs = ['en', 'ab', 'ja']
func s:doc_config_setup()
let s:helpfile_save = &helpfile
let &helpfile="Xdir1/doc-en/doc/testdoc.txt"
let &helpfile="Xdocdir1/doc-en/doc/testdoc.txt"
let s:rtp_save = &rtp
let &rtp="Xdir1/doc-en"
let &rtp="Xdocdir1/doc-en"
if has('multi_lang')
let s:helplang_save=&helplang
endif
call delete('Xdir1', 'rf')
call delete('Xdocdir1', 'rf')
for lang in s:langs
if lang ==# 'en'
@ -202,7 +202,7 @@ func s:doc_config_setup()
let tagfname = 'tags-' . lang
let docfname = 'testdoc.' . lang . 'x'
endif
let docdir = "Xdir1/doc-" . lang . "/doc"
let docdir = "Xdocdir1/doc-" . lang . "/doc"
call mkdir(docdir, "p")
call writefile(["\t*test-char*", "\t*test-col*"], docdir . '/' . docfname)
call writefile(["test-char\t" . docfname . "\t/*test-char*",
@ -212,7 +212,7 @@ func s:doc_config_setup()
endfunc
func s:doc_config_teardown()
call delete('Xdir1', 'rf')
call delete('Xdocdir1', 'rf')
let &helpfile = s:helpfile_save
let &rtp = s:rtp_save
@ -244,7 +244,7 @@ func Test_help_complete()
call assert_equal(['test-col', 'test-char'], list)
" 'helplang=' and help file lang is 'en' and 'ab'
set rtp+=Xdir1/doc-ab
set rtp+=Xdocdir1/doc-ab
set helplang=
let list = s:get_help_compl_list("test")
call assert_equal(sort(['test-col@en', 'test-col@ab',
@ -257,7 +257,7 @@ func Test_help_complete()
\ 'test-char', 'test-char@en']), sort(list))
" 'helplang=' and help file lang is 'en', 'ab' and 'ja'
set rtp+=Xdir1/doc-ja
set rtp+=Xdocdir1/doc-ja
set helplang=
let list = s:get_help_compl_list("test")
call assert_equal(sort(['test-col@en', 'test-col@ab',
@ -300,8 +300,8 @@ func Test_help_respect_current_file_lang()
helpclose
endfunc
set rtp+=Xdir1/doc-ab
set rtp+=Xdir1/doc-ja
set rtp+=Xdocdir1/doc-ab
set rtp+=Xdocdir1/doc-ja
set helplang=ab
call s:check_help_file_ext('test-char', 'abx')