patch 8.0.1260: using global variables for WaitFor()
Problem: Using global variables for WaitFor().
Solution: Use a lambda function instead. Don't check a condition if
WaitFor() already checked it.
diff --git a/src/testdir/test_quotestar.vim b/src/testdir/test_quotestar.vim
index b7d3158..cc975be 100644
--- a/src/testdir/test_quotestar.vim
+++ b/src/testdir/test_quotestar.vim
@@ -60,12 +60,8 @@
call assert_notmatch(name, serverlist())
let cmd .= ' --servername ' . name
- let g:job = job_start(cmd, {'stoponexit': 'kill', 'out_io': 'null'})
- call WaitFor('job_status(g:job) == "run"')
- if job_status(g:job) != 'run'
- call assert_report('Cannot run the Vim server')
- return ''
- endif
+ let job = job_start(cmd, {'stoponexit': 'kill', 'out_io': 'null'})
+ call WaitFor({-> job_status(job) == "run"})
" Takes a short while for the server to be active.
call WaitFor('serverlist() =~ "' . name . '"')
@@ -124,11 +120,14 @@
endif
call remote_send(name, ":qa!\<CR>")
- call WaitFor('job_status(g:job) == "dead"')
- if job_status(g:job) != 'dead'
- call assert_report('Server did not exit')
- call job_stop(g:job, 'kill')
- endif
+ try
+ call WaitFor({-> job_status(job) == "dead"})
+ finally
+ if job_status(job) != 'dead'
+ call assert_report('Server did not exit')
+ call job_stop(job, 'kill')
+ endif
+ endtry
return ''
endfunc