diff options
author | zeertzjq <zeertzjq@outlook.com> | 2025-02-19 14:32:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-19 06:32:45 +0000 |
commit | 9005134cdc8e578201b90192253171a9bc261752 (patch) | |
tree | 9d3b0bac4c55888b7c775c544151b55fd537311e | |
parent | 5d03060743da195ad2942201eed16708377c1a43 (diff) | |
download | rneovim-9005134cdc8e578201b90192253171a9bc261752.tar.gz rneovim-9005134cdc8e578201b90192253171a9bc261752.tar.bz2 rneovim-9005134cdc8e578201b90192253171a9bc261752.zip |
vim-patch:9.0.0532: edit test is flaky when run under valgrind (#32518)
Problem: Edit test is flaky when run under valgrind.
Solution: Send some text to the terminal to trigger a redraw.
https://github.com/vim/vim/commit/14f91765c07e147e0c8554a50560ae24dbd5ecea
Cherry-pick Test_edit_shift_bs() from patch 8.2.4876.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r-- | test/old/testdir/test_edit.vim | 79 |
1 files changed, 50 insertions, 29 deletions
diff --git a/test/old/testdir/test_edit.vim b/test/old/testdir/test_edit.vim index 9114cf8b11..f9458d69a3 100644 --- a/test/old/testdir/test_edit.vim +++ b/test/old/testdir/test_edit.vim @@ -472,7 +472,7 @@ func Test_edit_CR() " has been taken care of by other tests CheckFeature quickfix botright new - call writefile(range(1, 10), 'Xqflist.txt') + call writefile(range(1, 10), 'Xqflist.txt', 'D') call setqflist([{'filename': 'Xqflist.txt', 'lnum': 2}]) copen set modifiable @@ -492,16 +492,15 @@ func Test_edit_CR() call feedkeys("A\n", 'tnix') call feedkeys("A\r", 'tnix') call assert_equal(map(range(1, 10), 'string(v:val)') + ['', '', '', ''], getline(1, '$')) + bw! lclose - call delete('Xqflist.txt') endfunc func Test_edit_CTRL_() + CheckFeature rightleft " disabled for Windows builds, why? - if !has("rightleft") || has("win32") - return - endif + CheckNotMSWindows let _encoding=&encoding set encoding=utf-8 " Test for CTRL-_ @@ -592,7 +591,7 @@ func Test_edit_CTRL_I() call feedkeys("Arunt\<c-x>\<c-f>\<tab>\<cr>\<esc>", 'tnix') call assert_match('runtest\.vim', getline(1)) %d - call writefile(['one', 'two', 'three'], 'Xinclude.txt') + call writefile(['one', 'two', 'three'], 'Xinclude.txt', 'D') let include='#include Xinclude.txt' call setline(1, [include, '']) call cursor(2, 1) @@ -604,14 +603,13 @@ func Test_edit_CTRL_I() call assert_equal([include, 'three', ''], getline(1, '$')) call feedkeys("2ggC\<c-x>\<tab>\<down>\<down>\<down>\<cr>\<esc>", 'tnix') call assert_equal([include, '', ''], getline(1, '$')) - call delete("Xinclude.txt") bw! endfunc func Test_edit_CTRL_K() " Test pressing CTRL-K (basically only dictionary completion and digraphs " the rest is already covered - call writefile(['A', 'AA', 'AAA', 'AAAA'], 'Xdictionary.txt') + call writefile(['A', 'AA', 'AAA', 'AAAA'], 'Xdictionary.txt', 'D') set dictionary=Xdictionary.txt new call setline(1, 'A') @@ -667,7 +665,6 @@ func Test_edit_CTRL_K() " error sleeps 2 seconds, when v:testing is not set let v:testing = 0 endtry - call delete('Xdictionary.txt') if exists('*test_override') call test_override("char_avail", 1) @@ -867,7 +864,7 @@ func Test_edit_CTRL_T() call assert_equal(["\<tab>abcxyz"], getline(1, '$')) set nopaste " CTRL-X CTRL-T (thesaurus complete) - call writefile(['angry furious mad enraged'], 'Xthesaurus') + call writefile(['angry furious mad enraged'], 'Xthesaurus', 'D') set thesaurus=Xthesaurus call setline(1, 'mad') call cursor(1, 1) @@ -924,13 +921,12 @@ func Test_edit_CTRL_T() let v:testing = 0 endtry call assert_equal(['mad'], getline(1, '$')) - call delete('Xthesaurus') bw! endfunc " Test thesaurus completion with different encodings func Test_thesaurus_complete_with_encoding() - call writefile(['angry furious mad enraged'], 'Xthesaurus') + call writefile(['angry furious mad enraged'], 'Xthesaurus', 'D') set thesaurus=Xthesaurus " for e in ['latin1', 'utf-8'] for e in ['utf-8'] @@ -943,7 +939,6 @@ func Test_thesaurus_complete_with_encoding() bw! endfor set thesaurus= - call delete('Xthesaurus') endfunc " Test 'thesaurusfunc' @@ -1524,7 +1519,7 @@ func Test_edit_complete_very_long_name() let dirname = getcwd() . "/Xlongdir" let longdirname = dirname . repeat('/' . repeat('d', 255), 4) try - call mkdir(longdirname, 'p') + call mkdir(longdirname, 'pR') catch /E739:/ " Long directory name probably not supported. call delete(dirname, 'rf') @@ -1564,7 +1559,6 @@ func Test_edit_complete_very_long_name() bwipe! exe 'bwipe! ' . longfilename - call delete(dirname, 'rf') let &columns = save_columns if winposx >= 0 && winposy >= 0 exe 'winpos ' . winposx . ' ' . winposy @@ -1783,19 +1777,18 @@ endfunc " Test for editing a file using invalid file encoding func Test_edit_invalid_encoding() CheckEnglish - call writefile([], 'Xinvfile') + call writefile([], 'Xinvfile', 'D') redir => msg new ++enc=axbyc Xinvfile redir END call assert_match('\[NOT converted\]', msg) - call delete('Xinvfile') close! endfunc " Test for the "charconvert" option func Test_edit_charconvert() CheckEnglish - call writefile(['one', 'two'], 'Xccfile') + call writefile(['one', 'two'], 'Xccfile', 'D') " set 'charconvert' to a non-existing function set charconvert=NonExitingFunc() @@ -1855,8 +1848,6 @@ func Test_edit_charconvert() close! delfunc Cconv3 set charconvert& - - call delete('Xccfile') endfunc " Test for editing a file without read permission @@ -1864,7 +1855,7 @@ func Test_edit_file_no_read_perm() CheckUnix CheckNotRoot - call writefile(['one', 'two'], 'Xnrpfile') + call writefile(['one', 'two'], 'Xnrpfile', 'D') call setfperm('Xnrpfile', '-w-------') new redir => msg @@ -1874,7 +1865,6 @@ func Test_edit_file_no_read_perm() call assert_equal([''], getline(1, '$')) call assert_match('\[Permission Denied\]', msg) close! - call delete('Xnrpfile') endfunc " Using :edit without leaving 'insertmode' should not cause Insert mode to be @@ -1886,19 +1876,24 @@ func Test_edit_insertmode_ex_edit() set insertmode noruler inoremap <C-B> <Cmd>edit Xfoo<CR> END - call writefile(lines, 'Xtest_edit_insertmode_ex_edit') - - let buf = RunVimInTerminal('-S Xtest_edit_insertmode_ex_edit', #{rows: 6}) - " Somehow this can be very slow with valgrind. A separate TermWait() works - " better than a longer time with WaitForAssert() (why?) - call TermWait(buf, 1000) + call writefile(lines, 'Xtest_edit_insertmode_ex_edit', 'D') + + let buf = RunVimInTerminal('-S Xtest_edit_insertmode_ex_edit', #{rows: 6, wait_for_ruler: 0}) + " Somehow when using valgrind "INSERT" does not show up unless we send + " something to the terminal. + for i in range(30) + if term_getline(buf, 6) =~ 'INSERT' + break + endif + call term_sendkeys(buf, "-") + sleep 100m + endfor call WaitForAssert({-> assert_match('^-- INSERT --\s*$', term_getline(buf, 6))}) call term_sendkeys(buf, "\<C-B>\<C-L>") call WaitForAssert({-> assert_notmatch('^-- INSERT --\s*$', term_getline(buf, 6))}) " clean up call StopVimInTerminal(buf) - call delete('Xtest_edit_insertmode_ex_edit') endfunc " Pressing escape in 'insertmode' should beep @@ -2124,6 +2119,32 @@ func Test_edit_overlong_file_name() bwipe! endfunc +func Test_edit_shift_bs() + CheckMSWindows + + " FIXME: this works interactively, but the test fails + throw 'Skipped: Shift-Backspace Test not working correctly :(' + + " Need to run this in Win32 Terminal, do not use CheckRunVimInTerminal + if !has("terminal") + return + endif + + " Shift Backspace should work like Backspace in insert mode + let lines =<< trim END + call setline(1, ['abc']) + END + call writefile(lines, 'Xtest_edit_shift_bs', 'D') + + let buf = RunVimInTerminal('-S Xtest_edit_shift_bs', #{rows: 3}) + call term_sendkeys(buf, "A\<S-BS>-\<esc>") + call TermWait(buf, 50) + call assert_equal('ab-', term_getline(buf, 1)) + + " clean up + call StopVimInTerminal(buf) +endfunc + func Test_edit_Ctrl_RSB() new let g:triggered = [] |