comparison src/testdir/test_channel.vim @ 29249:0b47ef4e19b8 v8.2.5143

patch 8.2.5143: some tests fail when using valgrind Commit: https://github.com/vim/vim/commit/37bb3b111d08ce420e3cfd6ea3da3ed7428fbed1 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 21 17:40:47 2022 +0100 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.
author Bram Moolenaar <Bram@vim.org>
date Tue, 21 Jun 2022 18:45:08 +0200
parents 32f3b86352e6
children 5dd393285464
comparison
equal deleted inserted replaced
29248:6a718a4e17ce 29249:0b47ef4e19b8
1199 call assert_equal('something', ch_read(job)) 1199 call assert_equal('something', ch_read(job))
1200 finally 1200 finally
1201 call job_stop(job) 1201 call job_stop(job)
1202 endtry 1202 endtry
1203 1203
1204 let job = job_start(s:python . " test_channel_pipe.py something", 1204 " This causes spurious leak errors with valgrind.
1205 \ {'out_io': 'null', 'err_io': 'out'}) 1205 if !RunningWithValgrind()
1206 call assert_equal("run", job_status(job)) 1206 let job = job_start(s:python . " test_channel_pipe.py something",
1207 call job_stop(job) 1207 \ {'out_io': 'null', 'err_io': 'out'})
1208 1208 call assert_equal("run", job_status(job))
1209 let job = job_start(s:python . " test_channel_pipe.py something", 1209 call job_stop(job)
1210 \ {'in_io': 'null', 'out_io': 'null', 'err_io': 'null'}) 1210
1211 call assert_equal("run", job_status(job)) 1211 let job = job_start(s:python . " test_channel_pipe.py something",
1212 call assert_equal('channel fail', string(job_getchannel(job))) 1212 \ {'in_io': 'null', 'out_io': 'null', 'err_io': 'null'})
1213 call assert_equal('fail', ch_status(job)) 1213 call assert_equal("run", job_status(job))
1214 call assert_equal('no process', string(test_null_job())) 1214 call assert_equal('channel fail', string(job_getchannel(job)))
1215 call assert_equal('channel fail', string(test_null_channel())) 1215 call assert_equal('fail', ch_status(job))
1216 call job_stop(job) 1216 call assert_equal('no process', string(test_null_job()))
1217 call assert_equal('channel fail', string(test_null_channel()))
1218 call job_stop(job)
1219 endif
1217 endfunc 1220 endfunc
1218 1221
1219 func Test_pipe_to_buffer_raw() 1222 func Test_pipe_to_buffer_raw()
1220 let options = {'out_mode': 'raw', 'out_io': 'buffer', 'out_name': 'testout'} 1223 let options = {'out_mode': 'raw', 'out_io': 'buffer', 'out_name': 'testout'}
1221 split testout 1224 split testout
1758 call assert_fails("call job_start('ls', 1761 call assert_fails("call job_start('ls',
1759 \ {'out_io' : 'buffer', 'out_buf' : -1})", 'E475:') 1762 \ {'out_io' : 'buffer', 'out_buf' : -1})", 'E475:')
1760 call assert_fails("call job_start('ls', 1763 call assert_fails("call job_start('ls',
1761 \ {'err_io' : 'buffer', 'err_buf' : -1})", 'E475:') 1764 \ {'err_io' : 'buffer', 'err_buf' : -1})", 'E475:')
1762 1765
1766 let cmd = has('win32') ? "cmd /c dir" : "ls"
1767
1763 set nomodifiable 1768 set nomodifiable
1764 call assert_fails("call job_start('cmd /c dir', 1769 call assert_fails("call job_start(cmd,
1765 \ {'out_io' : 'buffer', 'out_buf' :" .. bufnr() .. "})", 'E21:') 1770 \ {'out_io' : 'buffer', 'out_buf' :" .. bufnr() .. "})", 'E21:')
1766 call assert_fails("call job_start('cmd /c dir', 1771 call assert_fails("call job_start(cmd,
1767 \ {'err_io' : 'buffer', 'err_buf' :" .. bufnr() .. "})", 'E21:') 1772 \ {'err_io' : 'buffer', 'err_buf' :" .. bufnr() .. "})", 'E21:')
1768 set modifiable 1773 set modifiable
1769 1774
1770 call assert_fails("call job_start('ls', {'in_io' : 'buffer'})", 'E915:') 1775 call assert_fails("call job_start(cmd, {'in_io' : 'buffer'})", 'E915:')
1771 1776
1772 edit! XXX 1777 edit! XXX
1773 let bnum = bufnr() 1778 let bnum = bufnr()
1774 enew 1779 enew
1775 call assert_fails("call job_start('ls', 1780 call assert_fails("call job_start(cmd,
1776 \ {'in_io' : 'buffer', 'in_buf' : bnum})", 'E918:') 1781 \ {'in_io' : 'buffer', 'in_buf' : bnum})", 'E918:')
1777 1782
1778 " Empty job tests 1783 " Empty job tests
1779 " This was crashing on MS-Windows. 1784 " This was crashing on MS-Windows.
1780 call assert_fails('let job = job_start([""])', 'E474:') 1785 call assert_fails('let job = job_start([""])', 'E474:')
1785 call assert_fails('call job_setoptions(test_null_job(), {})', 'E916:') 1790 call assert_fails('call job_setoptions(test_null_job(), {})', 'E916:')
1786 %bw! 1791 %bw!
1787 endfunc 1792 endfunc
1788 1793
1789 func Test_job_stop_immediately() 1794 func Test_job_stop_immediately()
1795 " With valgrind this causes spurious leak reports
1796 if RunningWithValgrind()
1797 return
1798 endif
1799
1790 let g:job = job_start([s:python, '-c', 'import time;time.sleep(10)']) 1800 let g:job = job_start([s:python, '-c', 'import time;time.sleep(10)'])
1791 try 1801 try
1792 eval g:job->job_stop() 1802 eval g:job->job_stop()
1793 call WaitForAssert({-> assert_equal('dead', job_status(g:job))}) 1803 call WaitForAssert({-> assert_equal('dead', job_status(g:job))})
1794 finally 1804 finally