]> granicus.if.org Git - vim/commitdiff
patch 8.1.0799: calling deleted function; test doesn't work on Mac v8.1.0799
authorBram Moolenaar <Bram@vim.org>
Wed, 23 Jan 2019 21:33:18 +0000 (22:33 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 23 Jan 2019 21:33:18 +0000 (22:33 +0100)
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)

src/testdir/test_channel.vim
src/testdir/test_terminal.vim
src/version.c

index d3f36f88e43952d15747be27f9afa2a8cc986952..15ca9ddbb52508c4c52a56efe8197aef9befd879 100644 (file)
@@ -1945,10 +1945,11 @@ func Test_job_start_in_timer()
   endif
 
   func OutCb(chan, msg)
+    let g:val += 1
   endfunc
 
   func ExitCb(job, status)
-    let g:val = 1
+    let g:val += 1
     call Resume()
   endfunc
 
@@ -1967,6 +1968,10 @@ func Test_job_start_in_timer()
   call timer_start(1, 'TimerCb')
   let elapsed = Standby(&ut)
   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)
 
   delfunc OutCb
index ea7d4b1b6aa9664eadfab18f02b016b1993fc607..821154a9f87e84b590271c8149429454adb5a5ad 100644 (file)
@@ -643,19 +643,17 @@ func Test_terminal_write_stdin()
 endfunc
 
 func Test_terminal_no_cmd()
-  " Does not work on Mac.
-  if has('mac')
-    return
-  endif
   let buf = term_start('NONE', {})
   call assert_notequal(0, buf)
 
   let pty = job_info(term_getjob(buf))['tty_out']
   call assert_notequal('', pty)
-  if has('win32')
-    silent exe '!start cmd /c "echo look here > ' . pty . '"'
-  else
+  if has('gui_running') && !has('win32')
+    " In the GUI job_start() doesn't work, it does not read from the 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
   call WaitForAssert({-> assert_match('look here', term_getline(buf, 1))})
 
index a260844d25b632098f697a40e832455168838a99..d5ea08645e5e8ba3b5cce061243c43cd32498149 100644 (file)
@@ -791,6 +791,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    799,
 /**/
     798,
 /**/