1
0
forked from aniani/vim

patch 8.1.0799: calling deleted function; test doesn't work on Mac

Problem:    Calling deleted function; test doesn't work on Mac.
Solution:   Wait for the function to be called before deleting it. Use a job
            to write to the pty, unless in the GUI. (Ozaki Kiichi,
            closes #3854)
This commit is contained in:
Bram Moolenaar
2019-01-23 22:33:18 +01:00
parent dd29ea1805
commit cfc15237ab
3 changed files with 13 additions and 8 deletions

View File

@@ -1945,10 +1945,11 @@ func Test_job_start_in_timer()
endif endif
func OutCb(chan, msg) func OutCb(chan, msg)
let g:val += 1
endfunc endfunc
func ExitCb(job, status) func ExitCb(job, status)
let g:val = 1 let g:val += 1
call Resume() call Resume()
endfunc endfunc
@@ -1967,6 +1968,10 @@ func Test_job_start_in_timer()
call timer_start(1, 'TimerCb') call timer_start(1, 'TimerCb')
let elapsed = Standby(&ut) let elapsed = Standby(&ut)
call assert_inrange(1, &ut / 2, elapsed) call assert_inrange(1, &ut / 2, elapsed)
" Wait for both OutCb() and ExitCb() to have been called before deleting
" them.
call WaitForAssert({-> assert_equal(2, g:val)})
call job_stop(g:job) call job_stop(g:job)
delfunc OutCb delfunc OutCb

View File

@@ -643,19 +643,17 @@ func Test_terminal_write_stdin()
endfunc endfunc
func Test_terminal_no_cmd() func Test_terminal_no_cmd()
" Does not work on Mac.
if has('mac')
return
endif
let buf = term_start('NONE', {}) let buf = term_start('NONE', {})
call assert_notequal(0, buf) call assert_notequal(0, buf)
let pty = job_info(term_getjob(buf))['tty_out'] let pty = job_info(term_getjob(buf))['tty_out']
call assert_notequal('', pty) call assert_notequal('', pty)
if has('win32') if has('gui_running') && !has('win32')
silent exe '!start cmd /c "echo look here > ' . pty . '"' " In the GUI job_start() doesn't work, it does not read from the pty.
else
call system('echo "look here" > ' . pty) call system('echo "look here" > ' . pty)
else
" Otherwise using a job works on all systems.
call job_start([&shell, &shellcmdflag, 'echo "look here" > ' . pty])
endif endif
call WaitForAssert({-> assert_match('look here', term_getline(buf, 1))}) call WaitForAssert({-> assert_match('look here', term_getline(buf, 1))})

View File

@@ -791,6 +791,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 */
/**/
799,
/**/ /**/
798, 798,
/**/ /**/