comparison src/testdir/test_channel.vim @ 20923:a9516192b1db v8.2.1013

patch 8.2.1013: channel tests can be a bit flaky Commit: https://github.com/vim/vim/commit/ec9b017b879cb744393aadd3d105ee5da1332437 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jun 19 19:10:59 2020 +0200 patch 8.2.1013: channel tests can be a bit flaky Problem: Channel tests can be a bit flaky. Solution: Set the g:test_is_flaky flag in SetUp().
author Bram Moolenaar <Bram@vim.org>
date Fri, 19 Jun 2020 19:15:04 +0200
parents 8d9229c4781a
children 6a4806e326dd
comparison
equal deleted inserted replaced
20922:5de8bf9182ba 20923:a9516192b1db
27 let s:localhost = 'localhost:' 27 let s:localhost = 'localhost:'
28 let s:testscript = 'test_channel.py' 28 let s:testscript = 'test_channel.py'
29 endif 29 endif
30 let s:chopt = {} 30 let s:chopt = {}
31 call ch_log(g:testfunc) 31 call ch_log(g:testfunc)
32
33 " Most tests use job_start(), which can be flaky
34 let g:test_is_flaky = 1
32 endfunc 35 endfunc
33 36
34 " Run "testfunc" after starting the server and stop the server afterwards. 37 " Run "testfunc" after starting the server and stop the server afterwards.
35 func s:run_server(testfunc, ...) 38 func s:run_server(testfunc, ...)
36 call RunServer(s:testscript, a:testfunc, a:000) 39 call RunServer(s:testscript, a:testfunc, a:000)
37
38 " communicating with a server can be flaky
39 let g:test_is_flaky = 1
40 endfunc 40 endfunc
41 41
42 " Return a list of open files. 42 " Return a list of open files.
43 " Can be used to make sure no resources leaked. 43 " Can be used to make sure no resources leaked.
44 " Returns an empty list on systems where this is not supported. 44 " Returns an empty list on systems where this is not supported.
453 453
454 " Test that trying to connect to a non-existing port fails quickly. 454 " Test that trying to connect to a non-existing port fails quickly.
455 func Test_connect_waittime() 455 func Test_connect_waittime()
456 CheckFunction reltimefloat 456 CheckFunction reltimefloat
457 " this is timing sensitive 457 " this is timing sensitive
458 let g:test_is_flaky = 1
459 458
460 let start = reltime() 459 let start = reltime()
461 let handle = ch_open('localhost:9876', s:chopt) 460 let handle = ch_open('localhost:9876', s:chopt)
462 if ch_status(handle) != "fail" 461 if ch_status(handle) != "fail"
463 " Oops, port does exists. 462 " Oops, port does exists.
1760 1759
1761 bwipe! test_buffer 1760 bwipe! test_buffer
1762 endfunc 1761 endfunc
1763 1762
1764 func Test_cmd_parsing() 1763 func Test_cmd_parsing()
1765 if !has('unix') 1764 CheckUnix
1766 return 1765
1767 endif
1768 call assert_false(filereadable("file with space")) 1766 call assert_false(filereadable("file with space"))
1769 let job = job_start('touch "file with space"') 1767 let job = job_start('touch "file with space"')
1770 call WaitForAssert({-> assert_true(filereadable("file with space"))}) 1768 call WaitForAssert({-> assert_true(filereadable("file with space"))})
1771 call delete("file with space") 1769 call delete("file with space")
1772 1770
1961 call s:test_list_args('print("hello\"world\"")', 'hello"world"', 1) 1959 call s:test_list_args('print("hello\"world\"")', 'hello"world"', 1)
1962 call s:test_list_args('print("hello\tworld")', "hello\tworld", 1) 1960 call s:test_list_args('print("hello\tworld")', "hello\tworld", 1)
1963 endfunc 1961 endfunc
1964 1962
1965 func Test_keep_pty_open() 1963 func Test_keep_pty_open()
1966 if !has('unix') 1964 CheckUnix
1967 return
1968 endif
1969 1965
1970 let job = job_start(s:python . ' -c "import time;time.sleep(0.2)"', 1966 let job = job_start(s:python . ' -c "import time;time.sleep(0.2)"',
1971 \ {'out_io': 'null', 'err_io': 'null', 'pty': 1}) 1967 \ {'out_io': 'null', 'err_io': 'null', 'pty': 1})
1972 let elapsed = WaitFor({-> job_status(job) ==# 'dead'}) 1968 let elapsed = WaitFor({-> job_status(job) ==# 'dead'})
1973 call assert_inrange(200, 1000, elapsed) 1969 call assert_inrange(200, 1000, elapsed)
2045 call job_stop(job) 2041 call job_stop(job)
2046 endtry 2042 endtry
2047 endfunc 2043 endfunc
2048 2044
2049 func Test_job_exitval_and_termsig() 2045 func Test_job_exitval_and_termsig()
2050 if !has('unix') 2046 CheckUnix
2051 return
2052 endif
2053 2047
2054 " Terminate job normally 2048 " Terminate job normally
2055 let cmd = ['echo'] 2049 let cmd = ['echo']
2056 let job = job_start(cmd) 2050 let job = job_start(cmd)
2057 call WaitForAssert({-> assert_equal("dead", job_status(job))}) 2051 call WaitForAssert({-> assert_equal("dead", job_status(job))})
2121 call delete('Xtesterr') 2115 call delete('Xtesterr')
2122 endfunc 2116 endfunc
2123 2117
2124 " Do this last, it stops any channel log. 2118 " Do this last, it stops any channel log.
2125 func Test_zz_nl_err_to_out_pipe() 2119 func Test_zz_nl_err_to_out_pipe()
2120
2126 eval 'Xlog'->ch_logfile() 2121 eval 'Xlog'->ch_logfile()
2127 call ch_log('Test_zz_nl_err_to_out_pipe()') 2122 call ch_log('Test_zz_nl_err_to_out_pipe()')
2128 let job = job_start(s:python . " test_channel_pipe.py", {'err_io': 'out'}) 2123 let job = job_start(s:python . " test_channel_pipe.py", {'err_io': 'out'})
2129 call assert_equal("run", job_status(job)) 2124 call assert_equal("run", job_status(job))
2130 try 2125 try
2212 endfunc 2207 endfunc
2213 2208
2214 func Test_job_trailing_space_unix() 2209 func Test_job_trailing_space_unix()
2215 CheckUnix 2210 CheckUnix
2216 CheckExecutable cat 2211 CheckExecutable cat
2212
2217 let job = job_start("cat ", #{in_io: 'null'}) 2213 let job = job_start("cat ", #{in_io: 'null'})
2218 call WaitForAssert({-> assert_equal("dead", job_status(job))}) 2214 call WaitForAssert({-> assert_equal("dead", job_status(job))})
2219 call assert_equal(0, job_info(job).exitval) 2215 call assert_equal(0, job_info(job).exitval)
2220 endfunc 2216 endfunc
2221 2217