0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

patch 8.2.5143: some tests fail when using valgrind

Problem:    Some tests fail when using valgrind. Spurious leak reports.
Solution:   Use WaitForAssert().  Avoid failing fork/exec.  Skip tests where a
            job is killed when running valgrind.
This commit is contained in:
Bram Moolenaar
2022-06-21 17:40:47 +01:00
parent fa04eae5a5
commit 37bb3b111d
5 changed files with 45 additions and 33 deletions

View File

@@ -1201,19 +1201,22 @@ func Test_pipe_null()
call job_stop(job) call job_stop(job)
endtry endtry
let job = job_start(s:python . " test_channel_pipe.py something", " This causes spurious leak errors with valgrind.
\ {'out_io': 'null', 'err_io': 'out'}) if !RunningWithValgrind()
call assert_equal("run", job_status(job)) let job = job_start(s:python . " test_channel_pipe.py something",
call job_stop(job) \ {'out_io': 'null', 'err_io': 'out'})
call assert_equal("run", job_status(job))
call job_stop(job)
let job = job_start(s:python . " test_channel_pipe.py something", let job = job_start(s:python . " test_channel_pipe.py something",
\ {'in_io': 'null', 'out_io': 'null', 'err_io': 'null'}) \ {'in_io': 'null', 'out_io': 'null', 'err_io': 'null'})
call assert_equal("run", job_status(job)) call assert_equal("run", job_status(job))
call assert_equal('channel fail', string(job_getchannel(job))) call assert_equal('channel fail', string(job_getchannel(job)))
call assert_equal('fail', ch_status(job)) call assert_equal('fail', ch_status(job))
call assert_equal('no process', string(test_null_job())) call assert_equal('no process', string(test_null_job()))
call assert_equal('channel fail', string(test_null_channel())) call assert_equal('channel fail', string(test_null_channel()))
call job_stop(job) call job_stop(job)
endif
endfunc endfunc
func Test_pipe_to_buffer_raw() func Test_pipe_to_buffer_raw()
@@ -1760,19 +1763,21 @@ func Test_job_start_fails()
call assert_fails("call job_start('ls', call assert_fails("call job_start('ls',
\ {'err_io' : 'buffer', 'err_buf' : -1})", 'E475:') \ {'err_io' : 'buffer', 'err_buf' : -1})", 'E475:')
let cmd = has('win32') ? "cmd /c dir" : "ls"
set nomodifiable set nomodifiable
call assert_fails("call job_start('cmd /c dir', call assert_fails("call job_start(cmd,
\ {'out_io' : 'buffer', 'out_buf' :" .. bufnr() .. "})", 'E21:') \ {'out_io' : 'buffer', 'out_buf' :" .. bufnr() .. "})", 'E21:')
call assert_fails("call job_start('cmd /c dir', call assert_fails("call job_start(cmd,
\ {'err_io' : 'buffer', 'err_buf' :" .. bufnr() .. "})", 'E21:') \ {'err_io' : 'buffer', 'err_buf' :" .. bufnr() .. "})", 'E21:')
set modifiable set modifiable
call assert_fails("call job_start('ls', {'in_io' : 'buffer'})", 'E915:') call assert_fails("call job_start(cmd, {'in_io' : 'buffer'})", 'E915:')
edit! XXX edit! XXX
let bnum = bufnr() let bnum = bufnr()
enew enew
call assert_fails("call job_start('ls', call assert_fails("call job_start(cmd,
\ {'in_io' : 'buffer', 'in_buf' : bnum})", 'E918:') \ {'in_io' : 'buffer', 'in_buf' : bnum})", 'E918:')
" Empty job tests " Empty job tests
@@ -1787,6 +1792,11 @@ func Test_job_start_fails()
endfunc endfunc
func Test_job_stop_immediately() func Test_job_stop_immediately()
" With valgrind this causes spurious leak reports
if RunningWithValgrind()
return
endif
let g:job = job_start([s:python, '-c', 'import time;time.sleep(10)']) let g:job = job_start([s:python, '-c', 'import time;time.sleep(10)'])
try try
eval g:job->job_stop() eval g:job->job_stop()

View File

@@ -244,10 +244,13 @@ func Test_cscopeWithCscopeConnections()
call assert_equal('', a) call assert_equal('', a)
" Test: 'csprg' option " Test: 'csprg' option
call assert_equal('cscope', &csprg) " Skip this with valgrind, it causes spurious leak reports
set csprg=doesnotexist if !RunningWithValgrind()
call assert_fails('cscope add Xcscope2.out', 'E262:') call assert_equal('cscope', &csprg)
set csprg=cscope set csprg=doesnotexist
call assert_fails('cscope add Xcscope2.out', 'E262:')
set csprg=cscope
endif
" Test: multiple cscope connections " Test: multiple cscope connections
cscope add Xcscope.out cscope add Xcscope.out

View File

@@ -81,11 +81,9 @@ func Test_imactivatefunc_imstatusfunc_callback_no_breaks_foldopen()
END END
call writefile(lines, 'Xscript') call writefile(lines, 'Xscript')
let buf = RunVimInTerminal('-S Xscript', {}) let buf = RunVimInTerminal('-S Xscript', {})
call term_wait(buf)
call assert_notequal('abc', term_getline(buf, 2)) call assert_notequal('abc', term_getline(buf, 2))
call term_sendkeys(buf, "/abc\n") call term_sendkeys(buf, "/abc\n")
call term_wait(buf) call WaitForAssert({-> assert_equal('abc', term_getline(buf, 2))})
call assert_equal('abc', term_getline(buf, 2))
" clean up " clean up
call StopVimInTerminal(buf) call StopVimInTerminal(buf)

View File

@@ -1177,13 +1177,12 @@ func Test_pum_rightleft()
END END
call writefile(lines, 'Xtest1') call writefile(lines, 'Xtest1')
let buf = RunVimInTerminal('--cmd "set rightleft" Xtest1', {}) let buf = RunVimInTerminal('--cmd "set rightleft" Xtest1', {})
call term_wait(buf)
call term_sendkeys(buf, "Go\<C-P>") call term_sendkeys(buf, "Go\<C-P>")
call VerifyScreenDump(buf, 'Test_pum_rightleft_01', {'rows': 8}) call VerifyScreenDump(buf, 'Test_pum_rightleft_01', {'rows': 8})
call term_sendkeys(buf, "\<C-P>\<C-Y>") call term_sendkeys(buf, "\<C-P>\<C-Y>")
call term_wait(buf) call TermWait(buf, 30)
redraw! redraw!
call assert_match('\s*miv', Screenline(5)) call WaitForAssert({-> assert_match('\s*miv', Screenline(5))})
" Test for expanding tabs to spaces in the popup menu " Test for expanding tabs to spaces in the popup menu
let lines =<< trim END let lines =<< trim END
@@ -1193,15 +1192,15 @@ func Test_pum_rightleft()
END END
call writefile(lines, 'Xtest2') call writefile(lines, 'Xtest2')
call term_sendkeys(buf, "\<Esc>:e! Xtest2\<CR>") call term_sendkeys(buf, "\<Esc>:e! Xtest2\<CR>")
call term_wait(buf) call TermWait(buf, 30)
call term_sendkeys(buf, "Goone\<C-X>\<C-L>") call term_sendkeys(buf, "Goone\<C-X>\<C-L>")
call term_wait(buf) call TermWait(buf, 30)
redraw! redraw!
call VerifyScreenDump(buf, 'Test_pum_rightleft_02', {'rows': 7}) call VerifyScreenDump(buf, 'Test_pum_rightleft_02', {'rows': 7})
call term_sendkeys(buf, "\<C-Y>") call term_sendkeys(buf, "\<C-Y>")
call term_wait(buf) call TermWait(buf, 30)
redraw! redraw!
call assert_match('\s*eerht eno', Screenline(4)) call WaitForAssert({-> assert_match('\s*eerht eno', Screenline(4))})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xtest1') call delete('Xtest1')
@@ -1218,15 +1217,15 @@ func Test_pum_scrollbar()
END END
call writefile(lines, 'Xtest1') call writefile(lines, 'Xtest1')
let buf = RunVimInTerminal('--cmd "set pumheight=2" Xtest1', {}) let buf = RunVimInTerminal('--cmd "set pumheight=2" Xtest1', {})
call term_wait(buf) call TermWait(buf)
call term_sendkeys(buf, "Go\<C-P>\<C-P>\<C-P>") call term_sendkeys(buf, "Go\<C-P>\<C-P>\<C-P>")
call VerifyScreenDump(buf, 'Test_pum_scrollbar_01', {'rows': 7}) call VerifyScreenDump(buf, 'Test_pum_scrollbar_01', {'rows': 7})
call term_sendkeys(buf, "\<C-E>\<Esc>dd") call term_sendkeys(buf, "\<C-E>\<Esc>dd")
call term_wait(buf) call TermWait(buf)
if has('rightleft') if has('rightleft')
call term_sendkeys(buf, ":set rightleft\<CR>") call term_sendkeys(buf, ":set rightleft\<CR>")
call term_wait(buf) call TermWait(buf)
call term_sendkeys(buf, "Go\<C-P>\<C-P>\<C-P>") call term_sendkeys(buf, "Go\<C-P>\<C-P>\<C-P>")
call VerifyScreenDump(buf, 'Test_pum_scrollbar_02', {'rows': 7}) call VerifyScreenDump(buf, 'Test_pum_scrollbar_02', {'rows': 7})
endif endif

View File

@@ -734,6 +734,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 */
/**/
5143,
/**/ /**/
5142, 5142,
/**/ /**/