Skip to content

Commit e0c31f6

Browse files
committed
patch 8.0.0392: GUI test fails with Athena and Motif
Problem: GUI test fails with Athena and Motif. Solution: Add test_ignore_error(). Use it to ignore the "failed to create input context" error.
1 parent 5f53dd3 commit e0c31f6

File tree

6 files changed

+58
-0
lines changed

6 files changed

+58
-0
lines changed

runtime/doc/eval.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2358,6 +2358,7 @@ test_alloc_fail({id}, {countdown}, {repeat})
23582358
test_autochdir() none enable 'autochdir' during startup
23592359
test_disable_char_avail({expr}) none test without typeahead
23602360
test_garbagecollect_now() none free memory right now for testing
2361+
test_ignore_error({expr}) none ignore a specific error
23612362
test_null_channel() Channel null value for testing
23622363
test_null_dict() Dict null value for testing
23632364
test_null_job() Job null value for testing
@@ -7784,6 +7785,15 @@ test_garbagecollect_now() *test_garbagecollect_now()*
77847785
internally, and |v:testing| must have been set before calling
77857786
any function.
77867787

7788+
test_ignore_error({expr}) *test_ignore_error()*
7789+
Ignore any error containing {expr}. A normal message is given
7790+
instead.
7791+
This is only meant to be used in tests, where catching the
7792+
error with try/catch cannot be used (because it skips over
7793+
following code).
7794+
{expr} is used literally, not as a pattern.
7795+
There is currently no way to revert this.
7796+
77877797
test_null_channel() *test_null_channel()*
77887798
Return a Channel that is null. Only useful for testing.
77897799
{only available when compiled with the +channel feature}

src/evalfunc.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ static void f_test_alloc_fail(typval_T *argvars, typval_T *rettv);
389389
static void f_test_autochdir(typval_T *argvars, typval_T *rettv);
390390
static void f_test_disable_char_avail(typval_T *argvars, typval_T *rettv);
391391
static void f_test_garbagecollect_now(typval_T *argvars, typval_T *rettv);
392+
static void f_test_ignore_error(typval_T *argvars, typval_T *rettv);
392393
#ifdef FEAT_JOB_CHANNEL
393394
static void f_test_null_channel(typval_T *argvars, typval_T *rettv);
394395
#endif
@@ -823,6 +824,7 @@ static struct fst
823824
{"test_autochdir", 0, 0, f_test_autochdir},
824825
{"test_disable_char_avail", 1, 1, f_test_disable_char_avail},
825826
{"test_garbagecollect_now", 0, 0, f_test_garbagecollect_now},
827+
{"test_ignore_error", 1, 1, f_test_ignore_error},
826828
#ifdef FEAT_JOB_CHANNEL
827829
{"test_null_channel", 0, 0, f_test_null_channel},
828830
#endif
@@ -12325,6 +12327,15 @@ f_test_garbagecollect_now(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
1232512327
garbage_collect(TRUE);
1232612328
}
1232712329

12330+
/*
12331+
* "test_ignore_error()" function
12332+
*/
12333+
static void
12334+
f_test_ignore_error(typval_T *argvars, typval_T *rettv UNUSED)
12335+
{
12336+
ignore_error_for_testing(get_tv_string(&argvars[0]));
12337+
}
12338+
1232812339
#ifdef FEAT_JOB_CHANNEL
1232912340
static void
1233012341
f_test_null_channel(typval_T *argvars UNUSED, typval_T *rettv)

src/message.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,31 @@ emsg_not_now(void)
539539
return FALSE;
540540
}
541541

542+
#ifdef FEAT_EVAL
543+
static garray_T ignore_error_list = GA_EMPTY;
544+
545+
void
546+
ignore_error_for_testing(char_u *error)
547+
{
548+
if (ignore_error_list.ga_itemsize == 0)
549+
ga_init2(&ignore_error_list, sizeof(char_u *), 1);
550+
551+
ga_add_string(&ignore_error_list, error);
552+
}
553+
554+
static int
555+
ignore_error(char_u *msg)
556+
{
557+
int i;
558+
559+
for (i = 0; i < ignore_error_list.ga_len; ++i)
560+
if (strstr((char *)msg,
561+
(char *)((char_u **)(ignore_error_list.ga_data))[i]) != NULL)
562+
return TRUE;
563+
return FALSE;
564+
}
565+
#endif
566+
542567
#if !defined(HAVE_STRERROR) || defined(PROTO)
543568
/*
544569
* Replacement for perror() that behaves more or less like emsg() was called.
@@ -577,6 +602,12 @@ emsg(char_u *s)
577602
if (emsg_not_now())
578603
return TRUE;
579604

605+
#ifdef FEAT_EVAL
606+
/* When testing some errors are turned into a normal message. */
607+
if (ignore_error(s))
608+
return msg(s);
609+
#endif
610+
580611
called_emsg = TRUE;
581612

582613
/*

src/proto/message.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ void trunc_string(char_u *s, char_u *buf, int room_in, int buflen);
88
void reset_last_sourcing(void);
99
void msg_source(int attr);
1010
int emsg_not_now(void);
11+
void ignore_error_for_testing(char_u *error);
1112
void do_perror(char *msg);
1213
int emsg(char_u *s);
1314
int emsg2(char_u *s, char_u *a1);

src/testdir/test_gui.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ endfunc
1717
" Test for resetting "secure" flag after GUI has started.
1818
" Must be run first.
1919
func Test_1_set_secure()
20+
" Ignore the "failed to create input context" error.
21+
call test_ignore_error('E285')
22+
2023
set exrc secure
2124
gui -f
2225
call assert_equal(1, has('gui_running'))

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
392,
767769
/**/
768770
391,
769771
/**/

0 commit comments

Comments
 (0)