test(remote): add tests for --remote

This also fixes a fair number of issues found in running the tests
This commit is contained in:
Charlie Groves
2022-02-24 10:47:41 -05:00
parent 70d2ab1583
commit 039e94f491
4 changed files with 184 additions and 48 deletions

View File

@@ -1997,7 +1997,7 @@ Array nvim_get_proc_children(Integer pid, Error *err)
DLOG("fallback to vim._os_proc_children()");
Array a = ARRAY_DICT_INIT;
ADD(a, INTEGER_OBJ(pid));
String s = cstr_to_string("return vim._os_proc_children(select(...))");
String s = cstr_to_string("return vim._os_proc_children(...)");
Object o = nlua_exec(s, a, err);
api_free_string(s);
api_free_array(a);

View File

@@ -821,7 +821,6 @@ static void handle_remote_client(mparm_T *params, int remote_args,
Boolean should_exit = true;
Boolean tabbed;
int files;
int t_argc = remote_args;
Array args = ARRAY_DICT_INIT;
@@ -839,12 +838,17 @@ static void handle_remote_client(mparm_T *params, int remote_args,
Object o = nlua_exec(s, a, &err);
api_free_string(s);
api_free_array(a);
if (ERROR_SET(&err)) {
mch_errmsg(err.msg);
mch_errmsg("\n");
os_exit(2);
}
if (o.type == kObjectTypeDictionary) {
rvobj.data.dictionary = o.data.dictionary;
} else if (!ERROR_SET(&err)) {
api_set_error(&err, kErrorTypeException,
"Function returned unexpected value");
} else {
mch_errmsg("vim._cs_remote returned unexpected value\n");
os_exit(3);
}
for (size_t i = 0; i < rvobj.data.dictionary.size ; i++) {
@@ -853,18 +857,15 @@ static void handle_remote_client(mparm_T *params, int remote_args,
tabbed = rvobj.data.dictionary.items[i].value.data.boolean;
} else if (strcmp(rvobj.data.dictionary.items[i].key.data, "should_exit") == 0) {
should_exit = rvobj.data.dictionary.items[i].value.data.boolean;
} else if (strcmp(rvobj.data.dictionary.items[i].key.data, "files") == 0) {
files = (int)rvobj.data.dictionary.items[i].value.data.integer;
}
}
if (should_exit) {
os_exit(0);
} else {
if (tabbed) {
params->window_count = files;
params->window_layout = WIN_TABS;
}
}
if (tabbed) {
params->window_count = argc - remote_args - 1;
params->window_layout = WIN_TABS;
}
}