Compare commits

...

4 Commits

Author SHA1 Message Date
Bram Moolenaar
37175409d7 patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Problem:    Tests use assert_true(0) and assert_false(1) to report errors.
Solution:   Use assert_report().
2017-03-18 20:18:45 +01:00
Bram Moolenaar
42205551b1 patch 8.0.0477: the client-server test may hang when failing
Problem:    The client-server test may hang when failing.
Solution:   Set a timer.  Add assert_report()
2017-03-18 19:42:22 +01:00
Bram Moolenaar
7a43cb9cb5 patch 8.0.0476: missing change to main.c
Problem:    Missing change to main.c.
Solution:   Add new function.
2017-03-18 18:15:16 +01:00
Bram Moolenaar
7416f3e73a patch 8.0.0475: not enough testing for the client-server feature
Problem:    Not enough testing for the client-server feature.
Solution:   Add more tests.  Add the remote_startserver() function.  Fix that
            a locally evaluated expression uses function-local variables.
2017-03-18 18:10:13 +01:00
22 changed files with 309 additions and 127 deletions

View File

@@ -1,4 +1,4 @@
*eval.txt* For Vim version 8.0. Last change: 2017 Mar 09
*eval.txt* For Vim version 8.0. Last change: 2017 Mar 18
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1986,16 +1986,23 @@ argidx() Number current index in the argument list
arglistid([{winnr} [, {tabnr}]]) Number argument list id
argv({nr}) String {nr} entry of the argument list
argv() List the argument list
assert_equal({exp}, {act} [, {msg}]) none assert {exp} is equal to {act}
assert_exception({error} [, {msg}]) none assert {error} is in v:exception
assert_fails({cmd} [, {error}]) none assert {cmd} fails
assert_false({actual} [, {msg}]) none assert {actual} is false
assert_equal({exp}, {act} [, {msg}])
none assert {exp} is equal to {act}
assert_exception({error} [, {msg}])
none assert {error} is in v:exception
assert_fails({cmd} [, {error}]) none assert {cmd} fails
assert_false({actual} [, {msg}])
none assert {actual} is false
assert_inrange({lower}, {upper}, {actual} [, {msg}])
none assert {actual} is inside the range
assert_match({pat}, {text} [, {msg}]) none assert {pat} matches {text}
assert_notequal({exp}, {act} [, {msg}]) none assert {exp} is not equal {act}
assert_notmatch({pat}, {text} [, {msg}]) none assert {pat} not matches {text}
assert_true({actual} [, {msg}]) none assert {actual} is true
assert_match({pat}, {text} [, {msg}])
none assert {pat} matches {text}
assert_notequal({exp}, {act} [, {msg}])
none assert {exp} is not equal {act}
assert_notmatch({pat}, {text} [, {msg}])
none assert {pat} not matches {text}
assert_report({msg}) none report a test failure
assert_true({actual} [, {msg}]) none assert {actual} is true
asin({expr}) Float arc sine of {expr}
atan({expr}) Float arc tangent of {expr}
atan2({expr1}, {expr2}) Float arc tangent of {expr1} / {expr2}
@@ -2262,6 +2269,8 @@ remote_peek({serverid} [, {retvar}])
remote_read({serverid}) String read reply string
remote_send({server}, {string} [, {idvar}])
String send key sequence
remote_startserver({name}) none become server {name}
String send key sequence
remove({list}, {idx} [, {end}]) any remove items {idx}-{end} from {list}
remove({dict}, {key}) any remove entry {key} from {dict}
rename({from}, {to}) Number rename (move) file from {from} to {to}
@@ -2581,7 +2590,10 @@ assert_notmatch({pattern}, {actual} [, {msg}])
The opposite of `assert_match()`: add an error message to
|v:errors| when {pattern} matches {actual}.
assert_true({actual} [, {msg}]) *assert_true()*
assert_report({msg}) *assert_report()*
Report a test failure directly, using {msg}.
assert_true({actual} [, {msg}]) *assert_true()*
When {actual} is not true an error message is added to
|v:errors|, like with |assert_equal()|.
A value is TRUE when it is a non-zero number. When {actual}
@@ -3923,11 +3935,14 @@ foldtext() Returns a String, to be displayed for a closed fold. This is
|v:foldstart|, |v:foldend| and |v:folddashes| variables.
The returned string looks like this: >
+-- 45 lines: abcdef
< The number of dashes depends on the foldlevel. The "45" is
the number of lines in the fold. "abcdef" is the text in the
first non-blank line of the fold. Leading white space, "//"
or "/*" and the text from the 'foldmarker' and 'commentstring'
options is removed.
< The number of leading dashes depends on the foldlevel. The
"45" is the number of lines in the fold. "abcdef" is the text
in the first non-blank line of the fold. Leading white space,
"//" or "/*" and the text from the 'foldmarker' and
'commentstring' options is removed.
When used to draw the actual foldtext, the rest of the line
will be filled with the fold char from the 'fillchars'
setting.
{not available when compiled without the |+folding| feature}
foldtextresult({lnum}) *foldtextresult()*
@@ -6372,6 +6387,7 @@ remote_send({server}, {string} [, {idvar}])
See also |clientserver| |RemoteReply|.
This function is not available in the |sandbox|.
{only available when compiled with the |+clientserver| feature}
Note: Any errors will be reported in the server and may mess
up the display.
Examples: >
@@ -6383,6 +6399,12 @@ remote_send({server}, {string} [, {idvar}])
:echo remote_send("gvim", ":sleep 10 | echo ".
\ 'server2client(expand("<client>"), "HELLO")<CR>')
<
*remote_startserver()* *E941* *E942*
remote_startserver({name})
Become the server {name}. This fails if already running as a
server, when |v:servername| is not empty.
{only available when compiled with the |+clientserver| feature}
remove({list}, {idx} [, {end}]) *remove()*
Without {end}: Remove the item at {idx} from |List| {list} and
return the item.

View File

@@ -9083,6 +9083,17 @@ assert_bool(typval_T *argvars, int isTrue)
}
}
void
assert_report(typval_T *argvars)
{
garray_T ga;
prepare_assert_error(&ga);
ga_concat(&ga, get_tv_string(&argvars[0]));
assert_error(&ga);
ga_clear(&ga);
}
void
assert_exception(typval_T *argvars)
{

View File

@@ -52,6 +52,7 @@ static void f_assert_inrange(typval_T *argvars, typval_T *rettv);
static void f_assert_match(typval_T *argvars, typval_T *rettv);
static void f_assert_notequal(typval_T *argvars, typval_T *rettv);
static void f_assert_notmatch(typval_T *argvars, typval_T *rettv);
static void f_assert_report(typval_T *argvars, typval_T *rettv);
static void f_assert_true(typval_T *argvars, typval_T *rettv);
#ifdef FEAT_FLOAT
static void f_asin(typval_T *argvars, typval_T *rettv);
@@ -307,6 +308,7 @@ static void f_remote_foreground(typval_T *argvars, typval_T *rettv);
static void f_remote_peek(typval_T *argvars, typval_T *rettv);
static void f_remote_read(typval_T *argvars, typval_T *rettv);
static void f_remote_send(typval_T *argvars, typval_T *rettv);
static void f_remote_startserver(typval_T *argvars, typval_T *rettv);
static void f_remove(typval_T *argvars, typval_T *rettv);
static void f_rename(typval_T *argvars, typval_T *rettv);
static void f_repeat(typval_T *argvars, typval_T *rettv);
@@ -482,6 +484,7 @@ static struct fst
{"assert_match", 2, 3, f_assert_match},
{"assert_notequal", 2, 3, f_assert_notequal},
{"assert_notmatch", 2, 3, f_assert_notmatch},
{"assert_report", 1, 1, f_assert_report},
{"assert_true", 1, 2, f_assert_true},
#ifdef FEAT_FLOAT
{"atan", 1, 1, f_atan},
@@ -741,6 +744,7 @@ static struct fst
{"remote_peek", 1, 2, f_remote_peek},
{"remote_read", 1, 1, f_remote_read},
{"remote_send", 2, 3, f_remote_send},
{"remote_startserver", 1, 1, f_remote_startserver},
{"remove", 2, 3, f_remove},
{"rename", 2, 2, f_rename},
{"repeat", 2, 2, f_repeat},
@@ -1311,6 +1315,15 @@ f_assert_notmatch(typval_T *argvars, typval_T *rettv UNUSED)
assert_match_common(argvars, ASSERT_NOTMATCH);
}
/*
* "assert_report(msg)" function
*/
static void
f_assert_report(typval_T *argvars, typval_T *rettv UNUSED)
{
assert_report(argvars);
}
/*
* "assert_true(actual[, msg])" function
*/
@@ -8487,7 +8500,7 @@ check_connection(void)
make_connection();
if (X_DISPLAY == NULL)
{
EMSG(_("E240: No connection to Vim server"));
EMSG(_("E240: No connection to the X server"));
return FAIL;
}
return OK;
@@ -8689,6 +8702,33 @@ f_remote_send(typval_T *argvars UNUSED, typval_T *rettv)
#endif
}
/*
* "remote_startserver()" function
*/
static void
f_remote_startserver(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
{
#ifdef FEAT_CLIENTSERVER
char_u *server = get_tv_string_chk(&argvars[0]);
if (server == NULL)
return; /* type error; errmsg already given */
if (serverName != NULL)
EMSG(_("E941: already started a server"));
else
{
# ifdef FEAT_X11
if (check_connection() == OK)
serverRegisterName(X_DISPLAY, server);
# else
serverSetName(server);
# endif
}
#else
EMSG(_("E942: +clientserver feature not available"));
#endif
}
/*
* "remove()" function
*/

View File

@@ -399,27 +399,7 @@ serverSendToVim(
/* Execute locally if no display or target is ourselves */
if (dpy == NULL || (serverName != NULL && STRICMP(name, serverName) == 0))
{
if (asExpr)
{
char_u *ret;
ret = eval_client_expr_to_string(cmd);
if (result != NULL)
{
if (ret == NULL)
*result = vim_strsave((char_u *)_(e_invexprmsg));
else
*result = ret;
}
else
vim_free(ret);
return ret == NULL ? -1 : 0;
}
else
server_to_input_buf(cmd);
return 0;
}
return sendToLocalVim(cmd, asExpr, result);
/*
* Bind the server name to a communication window.
@@ -616,6 +596,10 @@ ServerWait(
if (seconds >= 0 && (now - start) >= seconds)
break;
#ifdef FEAT_TIMERS
check_due_timer();
#endif
/* Just look out for the answer without calling back into Vim */
if (localLoop)
{
@@ -800,6 +784,7 @@ serverSendReply(char_u *name, char_u *str)
WaitForReply(void *p)
{
Window *w = (Window *) p;
return ServerReplyFind(*w, SROP_Find) != NULL;
}

View File

@@ -4140,6 +4140,11 @@ eval_client_expr_to_string(char_u *expr)
char_u *res;
int save_dbl = debug_break_level;
int save_ro = redir_off;
void *fc;
/* Evaluate the expression at the toplevel, don't use variables local to
* the calling function. */
fc = clear_current_funccal();
/* Disable debugging, otherwise Vim hangs, waiting for "cont" to be
* typed. */
@@ -4156,6 +4161,7 @@ eval_client_expr_to_string(char_u *expr)
--emsg_silent;
if (emsg_silent < 0)
emsg_silent = 0;
restore_current_funccal(fc);
/* A client can tell us to redraw, but not to display the cursor, so do
* that here. */
@@ -4169,6 +4175,41 @@ eval_client_expr_to_string(char_u *expr)
return res;
}
/*
* Evaluate a command or expression sent to ourselves.
*/
int
sendToLocalVim(char_u *cmd, int asExpr, char_u **result)
{
if (asExpr)
{
char_u *ret;
ret = eval_client_expr_to_string(cmd);
if (result != NULL)
{
if (ret == NULL)
{
char *err = _(e_invexprmsg);
size_t len = STRLEN(cmd) + STRLEN(err) + 5;
char_u *msg;
msg = alloc(len);
if (msg != NULL)
vim_snprintf((char *)msg, len, "%s: \"%s\"", err, cmd);
*result = msg;
}
else
*result = ret;
}
else
vim_free(ret);
return ret == NULL ? -1 : 0;
}
server_to_input_buf(cmd);
return 0;
}
/*
* If conversion is needed, convert "data" from "client_enc" to 'encoding' and
* return an allocated string. Otherwise return "data".

View File

@@ -2409,6 +2409,10 @@ serverSendToVim(
int retcode = 0;
char_u altname_buf[MAX_PATH];
/* Execute locally if no display or target is ourselves */
if (serverName != NULL && STRICMP(name, serverName) == 0)
return sendToLocalVim(cmd, asExpr, result);
/* If the server name does not end in a digit then we look for an
* alternate name. e.g. when "name" is GVIM the we may find GVIM2. */
if (STRLEN(name) > 1 && !vim_isdigit(name[STRLEN(name) - 1]))
@@ -2566,6 +2570,9 @@ serverGetReply(HWND server, int *expr_res, int remove, int wait)
/* Loop until we receive a reply */
while (reply_received == 0)
{
#ifdef FEAT_TIMERS
check_due_timer();
#endif
/* Wait for a SendMessage() call to us. This could be the reply
* we are waiting for. Use a timeout of a second, to catch the
* situation that the server died unexpectedly. */

View File

@@ -123,6 +123,7 @@ void assert_equal_common(typval_T *argvars, assert_type_T atype);
void assert_match_common(typval_T *argvars, assert_type_T atype);
void assert_inrange(typval_T *argvars);
void assert_bool(typval_T *argvars, int isTrue);
void assert_report(typval_T *argvars);
void assert_exception(typval_T *argvars);
void assert_fails(typval_T *argvars);
void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, char_u *exp_str, typval_T *exp_tv, typval_T *got_tv, assert_type_T atype);

View File

@@ -11,5 +11,6 @@ void time_pop(void *tp);
void time_msg(char *mesg, void *tv_start);
void server_to_input_buf(char_u *str);
char_u *eval_client_expr_to_string(char_u *expr);
int sendToLocalVim(char_u *cmd, int asExpr, char_u **result);
char_u *serverConvert(char_u *client_enc, char_u *data, char_u **tofree);
/* vim: set ft=c : */

View File

@@ -86,7 +86,7 @@ function GetAllocId(name)
return lnum - top - 1
endfunc
function RunTheTest(test)
func RunTheTest(test)
echo 'Executing ' . a:test
" Avoid stopping at the "hit enter" prompt
@@ -142,6 +142,60 @@ function RunTheTest(test)
set nomodified
endfunc
func AfterTheTest()
if len(v:errors) > 0
let s:fail += 1
call add(s:errors, 'Found errors in ' . s:test . ':')
call extend(s:errors, v:errors)
let v:errors = []
endif
endfunc
" This function can be called by a test if it wants to abort testing.
func FinishTesting()
call AfterTheTest()
" Don't write viminfo on exit.
set viminfo=
if s:fail == 0
" Success, create the .res file so that make knows it's done.
exe 'split ' . fnamemodify(g:testname, ':r') . '.res'
write
endif
if len(s:errors) > 0
" Append errors to test.log
split test.log
call append(line('$'), '')
call append(line('$'), 'From ' . g:testname . ':')
call append(line('$'), s:errors)
write
endif
let message = 'Executed ' . s:done . (s:done > 1 ? ' tests' : ' test')
echo message
call add(s:messages, message)
if s:fail > 0
let message = s:fail . ' FAILED:'
echo message
call add(s:messages, message)
call extend(s:messages, s:errors)
endif
" Add SKIPPED messages
call extend(s:messages, s:skipped)
" Append messages to the file "messages"
split messages
call append(line('$'), '')
call append(line('$'), 'From ' . g:testname . ':')
call append(line('$'), s:messages)
write
qall!
endfunc
" Source the test script. First grab the file name, in case the script
" navigates away. g:testname can be used by the tests.
let g:testname = expand('%')
@@ -164,6 +218,7 @@ endif
" Names of flaky tests.
let s:flaky = [
\ 'Test_client_server()',
\ 'Test_close_and_exit_cb()',
\ 'Test_collapse_buffers()',
\ 'Test_communicate()',
@@ -197,52 +252,9 @@ for s:test in sort(s:tests)
call RunTheTest(s:test)
endif
if len(v:errors) > 0
let s:fail += 1
call add(s:errors, 'Found errors in ' . s:test . ':')
call extend(s:errors, v:errors)
let v:errors = []
endif
call AfterTheTest()
endfor
" Don't write viminfo on exit.
set viminfo=
if s:fail == 0
" Success, create the .res file so that make knows it's done.
exe 'split ' . fnamemodify(g:testname, ':r') . '.res'
write
endif
if len(s:errors) > 0
" Append errors to test.log
split test.log
call append(line('$'), '')
call append(line('$'), 'From ' . g:testname . ':')
call append(line('$'), s:errors)
write
endif
let message = 'Executed ' . s:done . (s:done > 1 ? ' tests' : ' test')
echo message
call add(s:messages, message)
if s:fail > 0
let message = s:fail . ' FAILED:'
echo message
call add(s:messages, message)
call extend(s:messages, s:errors)
endif
" Add SKIPPED messages
call extend(s:messages, s:skipped)
" Append messages to the file "messages"
split messages
call append(line('$'), '')
call append(line('$'), 'From ' . g:testname . ':')
call append(line('$'), s:messages)
write
qall!
call FinishTesting()
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -36,6 +36,12 @@ func Test_assert_notequal()
call remove(v:errors, 0)
endfunc
func Test_assert_report()
call assert_report('something is wrong')
call assert_match('something is wrong', v:errors[0])
call remove(v:errors, 0)
endfunc
func Test_assert_exception()
try
nocommand

View File

@@ -8,10 +8,14 @@ source shared.vim
let s:python = PythonProg()
if s:python == ''
" Can't run this test.
" Can't run this test without Python.
finish
endif
" Uncomment the next line to see what happens. Output is in
" src/testdir/channellog.
" call ch_logfile('channellog', 'w')
let s:chopt = {}
" Run "testfunc" after sarting the server and stop the server afterwards.
@@ -31,7 +35,7 @@ func Ch_communicate(port)
let handle = ch_open('localhost:' . a:port, s:chopt)
unlet s:chopt.drop
if ch_status(handle) == "fail"
call assert_false(1, "Can't open channel")
call assert_report("Can't open channel")
return
endif
if has('job')
@@ -93,7 +97,7 @@ func Ch_communicate(port)
call ch_sendexpr(handle, 'hello!', {'callback': 'Ch_requestHandler'})
call WaitFor('exists("g:Ch_responseHandle")')
if !exists('g:Ch_responseHandle')
call assert_false(1, 'g:Ch_responseHandle was not set')
call assert_report('g:Ch_responseHandle was not set')
else
call assert_equal(handle, g:Ch_responseHandle)
unlet g:Ch_responseHandle
@@ -104,7 +108,7 @@ func Ch_communicate(port)
call ch_sendexpr(handle, 'hello!', {'callback': function('Ch_requestHandler')})
call WaitFor('exists("g:Ch_responseHandle")')
if !exists('g:Ch_responseHandle')
call assert_false(1, 'g:Ch_responseHandle was not set')
call assert_report('g:Ch_responseHandle was not set')
else
call assert_equal(handle, g:Ch_responseHandle)
unlet g:Ch_responseHandle
@@ -116,7 +120,7 @@ func Ch_communicate(port)
call ch_sendexpr(handle, 'hello!', {'callback': {a, b -> Ch_requestHandler(a, b)}})
call WaitFor('exists("g:Ch_responseHandle")')
if !exists('g:Ch_responseHandle')
call assert_false(1, 'g:Ch_responseHandle was not set')
call assert_report('g:Ch_responseHandle was not set')
else
call assert_equal(handle, g:Ch_responseHandle)
unlet g:Ch_responseHandle
@@ -209,7 +213,7 @@ func Ch_two_channels(port)
let handle = ch_open('localhost:' . a:port, s:chopt)
call assert_equal(v:t_channel, type(handle))
if ch_status(handle) == "fail"
call assert_false(1, "Can't open channel")
call assert_report("Can't open channel")
return
endif
@@ -217,7 +221,7 @@ func Ch_two_channels(port)
let newhandle = ch_open('localhost:' . a:port, s:chopt)
if ch_status(newhandle) == "fail"
call assert_false(1, "Can't open second channel")
call assert_report("Can't open second channel")
return
endif
call assert_equal('got it', ch_evalexpr(newhandle, 'hello!'))
@@ -238,7 +242,7 @@ endfunc
func Ch_server_crash(port)
let handle = ch_open('localhost:' . a:port, s:chopt)
if ch_status(handle) == "fail"
call assert_false(1, "Can't open channel")
call assert_report("Can't open channel")
return
endif
@@ -263,7 +267,7 @@ endfunc
func Ch_channel_handler(port)
let handle = ch_open('localhost:' . a:port, s:chopt)
if ch_status(handle) == "fail"
call assert_false(1, "Can't open channel")
call assert_report("Can't open channel")
return
endif
@@ -306,7 +310,7 @@ endfunc
func Ch_channel_zero(port)
let handle = ch_open('localhost:' . a:port, s:chopt)
if ch_status(handle) == "fail"
call assert_false(1, "Can't open channel")
call assert_report("Can't open channel")
return
endif
@@ -373,7 +377,7 @@ endfunc
func Ch_raw_one_time_callback(port)
let handle = ch_open('localhost:' . a:port, s:chopt)
if ch_status(handle) == "fail"
call assert_false(1, "Can't open channel")
call assert_report("Can't open channel")
return
endif
call ch_setoptions(handle, {'mode': 'raw'})
@@ -429,7 +433,7 @@ func Test_connect_waittime()
endif
catch
if v:exception !~ 'Connection reset by peer'
call assert_false(1, "Caught exception: " . v:exception)
call assert_report("Caught exception: " . v:exception)
endif
endtry
endfunc
@@ -1343,7 +1347,7 @@ func Ch_open_delay(port)
let channel = ch_open('localhost:' . a:port, s:chopt)
unlet s:chopt.waittime
if ch_status(channel) == "fail"
call assert_false(1, "Can't open channel")
call assert_report("Can't open channel")
return
endif
call assert_equal('got it', ch_evalexpr(channel, 'hello!'))
@@ -1365,7 +1369,7 @@ endfunc
function Ch_test_call(port)
let handle = ch_open('localhost:' . a:port, s:chopt)
if ch_status(handle) == "fail"
call assert_false(1, "Can't open channel")
call assert_report("Can't open channel")
return
endif
@@ -1463,7 +1467,7 @@ endfunc
function Ch_test_close_callback(port)
let handle = ch_open('localhost:' . a:port, s:chopt)
if ch_status(handle) == "fail"
call assert_false(1, "Can't open channel")
call assert_report("Can't open channel")
return
endif
call ch_setoptions(handle, {'close_cb': 'MyCloseCb'})
@@ -1481,7 +1485,7 @@ endfunc
function Ch_test_close_partial(port)
let handle = ch_open('localhost:' . a:port, s:chopt)
if ch_status(handle) == "fail"
call assert_false(1, "Can't open channel")
call assert_report("Can't open channel")
return
endif
let g:Ch_d = {}
@@ -1631,7 +1635,7 @@ endfunc
function Ch_test_close_lambda(port)
let handle = ch_open('localhost:' . a:port, s:chopt)
if ch_status(handle) == "fail"
call assert_false(1, "Can't open channel")
call assert_report("Can't open channel")
return
endif
let g:Ch_close_ret = ''
@@ -1646,6 +1650,3 @@ func Test_close_lambda()
call ch_log('Test_close_lambda()')
call s:run_server('Ch_test_close_lambda')
endfunc
" Uncomment this to see what happens, output is in src/testdir/channellog.
" call ch_logfile('channellog', 'w')

View File

@@ -6,34 +6,87 @@ endif
source shared.vim
let s:where = 0
func Abort(id)
call assert_report('Test timed out at ' . s:where)
call FinishTesting()
endfunc
func Test_client_server()
let cmd = GetVimCommand()
if cmd == ''
return
endif
let name = 'XVIMTEXT'
" Some of these commands may hang when failing.
call timer_start(10000, 'Abort')
let s:where = 1
let name = 'XVIMTEST'
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_true(0, 'Cannot run the Vim server')
call assert_report('Cannot run the Vim server')
return
endif
let s:where = 2
" Takes a short while for the server to be active.
call WaitFor('serverlist() =~ "' . name . '"')
call assert_match(name, serverlist())
let s:where = 3
call remote_foreground(name)
let s:where = 4
call remote_send(name, ":let testvar = 'yes'\<CR>")
let s:where = 5
call WaitFor('remote_expr("' . name . '", "testvar") == "yes"')
let s:where = 6
call assert_equal('yes', remote_expr(name, "testvar"))
let s:where = 7
if has('unix') && has('gui') && !has('gui_running')
" Running in a terminal and the GUI is avaiable: Tell the server to open
" the GUI and check that the remote command still works.
" Need to wait for the GUI to start up, otherwise the send hangs in trying
" to send to the terminal window.
call remote_send(name, ":gui -f\<CR>")
let s:where = 8
sleep 500m
call remote_send(name, ":let testvar = 'maybe'\<CR>")
let s:where = 9
call WaitFor('remote_expr("' . name . '", "testvar") == "maybe"')
let s:where = 10
call assert_equal('maybe', remote_expr(name, "testvar"))
let s:where = 11
endif
call assert_fails('call remote_send("XXX", ":let testvar = ''yes''\<CR>")', 'E241')
let s:where = 12
" Expression evaluated locally.
if v:servername == ''
call remote_startserver('MYSELF')
let s:where = 13
call assert_equal('MYSELF', v:servername)
endif
let g:testvar = 'myself'
call assert_equal('myself', remote_expr(v:servername, 'testvar'))
let s:where = 14
call remote_send(name, ":call server2client(expand('<client>'), 'got it')\<CR>", 'g:myserverid')
let s:where = 15
call assert_equal('got it', remote_read(g:myserverid))
let s:where = 16
call remote_send(name, ":qa!\<CR>")
let s:where = 17
call WaitFor('job_status(g:job) == "dead"')
let s:where = 18
if job_status(g:job) != 'dead'
call assert_true(0, 'Server did not exit')
call assert_report('Server did not exit')
call job_stop(g:job, 'kill')
endif
endfunc

View File

@@ -28,7 +28,7 @@ func Test_cscopeWithCscopeConnections()
cscope add Xcscope.out
set cscopeverbose
catch
call assert_true(0)
call assert_report('exception thrown')
endtry
call assert_fails('cscope add', 'E560')
call assert_fails('cscope add Xcscope.out', 'E568')

View File

@@ -1,13 +1,7 @@
" Tests for cursor().
func Test_wrong_arguments()
try
call cursor(1. 3)
" not reached
call assert_false(1)
catch
call assert_exception('E474:')
endtry
call assert_fails('call cursor(1. 3)', 'E474:')
endfunc
func Test_move_cursor()

View File

@@ -87,7 +87,7 @@ endfunc
func Test_loop_over_null_list()
let null_list = test_null_list()
for i in null_list
call assert_true(0, 'should not get here')
call assert_report('should not get here')
endfor
endfunc

View File

@@ -505,7 +505,7 @@ func Test_set_guifontwide()
" Case 2: guifontset is invalid
try
set guifontset=-*-notexist-*
call assert_false(1, "'set guifontset=-*-notexist-*' should have failed")
call assert_report("'set guifontset=-*-notexist-*' should have failed")
catch
call assert_exception('E598')
endtry

View File

@@ -8,7 +8,7 @@ func Test_load_menu()
try
source $VIMRUNTIME/menu.vim
catch
call assert_false(1, 'error while loading menus: ' . v:exception)
call assert_report('error while loading menus: ' . v:exception)
endtry
call assert_match('browse confirm w', execute(':menu File.Save'))
source $VIMRUNTIME/delmenu.vim

View File

@@ -132,7 +132,7 @@ func <SID>catch_peval(expr)
catch
return v:exception
endtry
call assert_true(0, 'no exception for `perleval("'.a:expr.'")`')
call assert_report('no exception for `perleval("'.a:expr.'")`')
return ''
endfunc

View File

@@ -562,7 +562,7 @@ func Test_completion_comment_formatting()
%d
try
call feedkeys("o/*\<cr>\<cr>\<c-x>\<c-u>/\<esc>", 'tx')
call assert_false(1, 'completefunc not set, should have failed')
call assert_report('completefunc not set, should have failed')
catch
call assert_exception('E764:')
endtry

View File

@@ -450,13 +450,13 @@ func Test_viminfo_file_mark_tabclose()
let lnum = line('.')
while 1
if lnum == line('$')
call assert_false(1, 'mark not found in Xtestfileintab')
call assert_report('mark not found in Xtestfileintab')
break
endif
let lnum += 1
let line = getline(lnum)
if line == ''
call assert_false(1, 'mark not found in Xtestfileintab')
call assert_report('mark not found in Xtestfileintab')
break
endif
if line =~ "^\t\""

View File

@@ -1256,14 +1256,14 @@ func Test_script_lines()
\ '.',
\ ])
catch
call assert_false(1, "Can't define function")
call assert_report("Can't define function")
endtry
try
call DefineFunction('T_Append', [
\ 'append',
\ 'abc',
\ ])
call assert_false(1, "Shouldn't be able to define function")
call assert_report("Shouldn't be able to define function")
catch
call assert_exception('Vim(function):E126: Missing :endfunction')
endtry
@@ -1276,14 +1276,14 @@ func Test_script_lines()
\ '.',
\ ])
catch
call assert_false(1, "Can't define function")
call assert_report("Can't define function")
endtry
try
call DefineFunction('T_Change', [
\ 'change',
\ 'abc',
\ ])
call assert_false(1, "Shouldn't be able to define function")
call assert_report("Shouldn't be able to define function")
catch
call assert_exception('Vim(function):E126: Missing :endfunction')
endtry
@@ -1296,14 +1296,14 @@ func Test_script_lines()
\ '.',
\ ])
catch
call assert_false(1, "Can't define function")
call assert_report("Can't define function")
endtry
try
call DefineFunction('T_Insert', [
\ 'insert',
\ 'abc',
\ ])
call assert_false(1, "Shouldn't be able to define function")
call assert_report("Shouldn't be able to define function")
catch
call assert_exception('Vim(function):E126: Missing :endfunction')
endtry

View File

@@ -764,6 +764,14 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
478,
/**/
477,
/**/
476,
/**/
475,
/**/
474,
/**/