mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 9.1.0269: Test for TextChanged is still flaky with ASAN
Problem: Test for TextChanged is still flaky with ASAN. Solution: Don't index the result of readfile(). (zeertzjq) It turns out that with ASAN the file may become empty during a write even if it's non-empty both before and after the write, in which case indexing the result of readfile() will error, so use join() instead. Also don't delete the file halfway the test, just in case it may cause errors on the next read. closes: #14421 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
83cd2c7bf0
commit
e9ff79a7c9
@ -4495,39 +4495,40 @@ func Test_Changed_ChangedI()
|
|||||||
\ {'term_rows': 10})
|
\ {'term_rows': 10})
|
||||||
call assert_equal('running', term_getstatus(buf))
|
call assert_equal('running', term_getstatus(buf))
|
||||||
call WaitForAssert({-> assert_true(filereadable('XTextChangedI3'))})
|
call WaitForAssert({-> assert_true(filereadable('XTextChangedI3'))})
|
||||||
|
defer delete('XTextChangedI3')
|
||||||
call WaitForAssert({-> assert_equal([''], readfile('XTextChangedI3'))})
|
call WaitForAssert({-> assert_equal([''], readfile('XTextChangedI3'))})
|
||||||
|
|
||||||
" TextChanged should trigger if a mapping enters and leaves Insert mode.
|
" TextChanged should trigger if a mapping enters and leaves Insert mode.
|
||||||
call term_sendkeys(buf, "\<CR>")
|
call term_sendkeys(buf, "\<CR>")
|
||||||
call WaitForAssert({-> assert_equal('N4,', readfile('XTextChangedI3')[0])})
|
call WaitForAssert({-> assert_equal('N4,', readfile('XTextChangedI3')->join("\n"))})
|
||||||
|
|
||||||
call term_sendkeys(buf, "i")
|
call term_sendkeys(buf, "i")
|
||||||
call WaitForAssert({-> assert_match('^-- INSERT --', term_getline(buf, 10))})
|
call WaitForAssert({-> assert_match('^-- INSERT --', term_getline(buf, 10))})
|
||||||
call WaitForAssert({-> assert_equal('N4,', readfile('XTextChangedI3')[0])})
|
call WaitForAssert({-> assert_equal('N4,', readfile('XTextChangedI3')->join("\n"))})
|
||||||
" TextChangedI should trigger if change is done in Insert mode.
|
" TextChangedI should trigger if change is done in Insert mode.
|
||||||
call term_sendkeys(buf, "f")
|
call term_sendkeys(buf, "f")
|
||||||
call WaitForAssert({-> assert_equal('N4,I5', readfile('XTextChangedI3')[0])})
|
call WaitForAssert({-> assert_equal('N4,I5', readfile('XTextChangedI3')->join("\n"))})
|
||||||
call term_sendkeys(buf, "o")
|
call term_sendkeys(buf, "o")
|
||||||
call WaitForAssert({-> assert_equal('N4,I6', readfile('XTextChangedI3')[0])})
|
call WaitForAssert({-> assert_equal('N4,I6', readfile('XTextChangedI3')->join("\n"))})
|
||||||
call term_sendkeys(buf, "o")
|
call term_sendkeys(buf, "o")
|
||||||
call WaitForAssert({-> assert_equal('N4,I7', readfile('XTextChangedI3')[0])})
|
call WaitForAssert({-> assert_equal('N4,I7', readfile('XTextChangedI3')->join("\n"))})
|
||||||
" TextChanged shouldn't trigger when leaving Insert mode and TextChangedI
|
" TextChanged shouldn't trigger when leaving Insert mode and TextChangedI
|
||||||
" has been triggered.
|
" has been triggered.
|
||||||
call term_sendkeys(buf, "\<Esc>")
|
call term_sendkeys(buf, "\<Esc>")
|
||||||
call WaitForAssert({-> assert_notmatch('^-- INSERT --', term_getline(buf, 10))})
|
call WaitForAssert({-> assert_notmatch('^-- INSERT --', term_getline(buf, 10))})
|
||||||
call WaitForAssert({-> assert_equal('N4,I7', readfile('XTextChangedI3')[0])})
|
call WaitForAssert({-> assert_equal('N4,I7', readfile('XTextChangedI3')->join("\n"))})
|
||||||
|
|
||||||
" TextChanged should trigger if change is done in Normal mode.
|
" TextChanged should trigger if change is done in Normal mode.
|
||||||
call term_sendkeys(buf, "yyp")
|
call term_sendkeys(buf, "yyp")
|
||||||
call WaitForAssert({-> assert_equal('N8,I7', readfile('XTextChangedI3')[0])})
|
call WaitForAssert({-> assert_equal('N8,I7', readfile('XTextChangedI3')->join("\n"))})
|
||||||
|
|
||||||
" TextChangedI shouldn't trigger if change isn't done in Insert mode.
|
" TextChangedI shouldn't trigger if change isn't done in Insert mode.
|
||||||
call term_sendkeys(buf, "i")
|
call term_sendkeys(buf, "i")
|
||||||
call WaitForAssert({-> assert_match('^-- INSERT --', term_getline(buf, 10))})
|
call WaitForAssert({-> assert_match('^-- INSERT --', term_getline(buf, 10))})
|
||||||
call WaitForAssert({-> assert_equal('N8,I7', readfile('XTextChangedI3')[0])})
|
call WaitForAssert({-> assert_equal('N8,I7', readfile('XTextChangedI3')->join("\n"))})
|
||||||
call term_sendkeys(buf, "\<Esc>")
|
call term_sendkeys(buf, "\<Esc>")
|
||||||
call WaitForAssert({-> assert_notmatch('^-- INSERT --', term_getline(buf, 10))})
|
call WaitForAssert({-> assert_notmatch('^-- INSERT --', term_getline(buf, 10))})
|
||||||
call WaitForAssert({-> assert_equal('N8,I7', readfile('XTextChangedI3')[0])})
|
call WaitForAssert({-> assert_equal('N8,I7', readfile('XTextChangedI3')->join("\n"))})
|
||||||
|
|
||||||
" TextChangedI should trigger if change is a mix of Normal and Insert modes.
|
" TextChangedI should trigger if change is a mix of Normal and Insert modes.
|
||||||
func! s:validate_mixed_textchangedi(buf, keys)
|
func! s:validate_mixed_textchangedi(buf, keys)
|
||||||
@ -4537,13 +4538,13 @@ func Test_Changed_ChangedI()
|
|||||||
call term_sendkeys(buf, "\<Esc>")
|
call term_sendkeys(buf, "\<Esc>")
|
||||||
call WaitForAssert({-> assert_notmatch('^-- INSERT --', term_getline(buf, 10))})
|
call WaitForAssert({-> assert_notmatch('^-- INSERT --', term_getline(buf, 10))})
|
||||||
call term_sendkeys(buf, ":let [g:autocmd_n, g:autocmd_i] = ['', '']\<CR>")
|
call term_sendkeys(buf, ":let [g:autocmd_n, g:autocmd_i] = ['', '']\<CR>")
|
||||||
call delete('XTextChangedI3')
|
call writefile([], 'XTextChangedI3')
|
||||||
call term_sendkeys(buf, a:keys)
|
call term_sendkeys(buf, a:keys)
|
||||||
call WaitForAssert({-> assert_match('^-- INSERT --', term_getline(buf, 10))})
|
call WaitForAssert({-> assert_match('^-- INSERT --', term_getline(buf, 10))})
|
||||||
call WaitForAssert({-> assert_match('^,I\d\+', readfile('XTextChangedI3')[0])})
|
call WaitForAssert({-> assert_match('^,I\d\+', readfile('XTextChangedI3')->join("\n"))})
|
||||||
call term_sendkeys(buf, "\<Esc>")
|
call term_sendkeys(buf, "\<Esc>")
|
||||||
call WaitForAssert({-> assert_notmatch('^-- INSERT --', term_getline(buf, 10))})
|
call WaitForAssert({-> assert_notmatch('^-- INSERT --', term_getline(buf, 10))})
|
||||||
call WaitForAssert({-> assert_match('^,I\d\+', readfile('XTextChangedI3')[0])})
|
call WaitForAssert({-> assert_match('^,I\d\+', readfile('XTextChangedI3')->join("\n"))})
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
call s:validate_mixed_textchangedi(buf, "o")
|
call s:validate_mixed_textchangedi(buf, "o")
|
||||||
@ -4556,7 +4557,6 @@ func Test_Changed_ChangedI()
|
|||||||
|
|
||||||
" clean up
|
" clean up
|
||||||
bwipe!
|
bwipe!
|
||||||
call delete('XTextChangedI3')
|
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test that filetype detection still works when SwapExists autocommand sets
|
" Test that filetype detection still works when SwapExists autocommand sets
|
||||||
|
@ -704,6 +704,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
269,
|
||||||
/**/
|
/**/
|
||||||
268,
|
268,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user