]> granicus.if.org Git - vim/commitdiff
patch 8.0.0392: GUI test fails with Athena and Motif v8.0.0392
authorBram Moolenaar <Bram@vim.org>
Wed, 1 Mar 2017 14:07:05 +0000 (15:07 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 1 Mar 2017 14:07:05 +0000 (15:07 +0100)
Problem:    GUI test fails with Athena and Motif.
Solution:   Add test_ignore_error().  Use it to ignore the "failed to create
            input context" error.

runtime/doc/eval.txt
src/evalfunc.c
src/message.c
src/proto/message.pro
src/testdir/test_gui.vim
src/version.c

index 30e71345a67bdd06b484e20d812697cbc3600ab8..f2ec3063dd7f07be2ffbf286f372e4fdd891ae25 100644 (file)
@@ -2358,6 +2358,7 @@ test_alloc_fail({id}, {countdown}, {repeat})
 test_autochdir()               none    enable 'autochdir' during startup
 test_disable_char_avail({expr}) none   test without typeahead
 test_garbagecollect_now()      none    free memory right now for testing
+test_ignore_error({expr})      none    ignore a specific error
 test_null_channel()            Channel null value for testing
 test_null_dict()               Dict    null value for testing
 test_null_job()                        Job     null value for testing
@@ -7784,6 +7785,15 @@ test_garbagecollect_now()                         *test_garbagecollect_now()*
                internally, and |v:testing| must have been set before calling
                any function.
 
+test_ignore_error({expr})                       *test_ignore_error()*
+               Ignore any error containing {expr}.  A normal message is given
+               instead.
+               This is only meant to be used in tests, where catching the
+               error with try/catch cannot be used (because it skips over
+               following code).
+               {expr} is used literally, not as a pattern.
+               There is currently no way to revert this.
+
 test_null_channel()                                    *test_null_channel()*
                Return a Channel that is null. Only useful for testing.
                {only available when compiled with the +channel feature}
index 52527bc897f5c04e2733dce0f63c32bf6345f9be..a470ff996f504647b2897bc1615f89e12e79639f 100644 (file)
@@ -389,6 +389,7 @@ static void f_test_alloc_fail(typval_T *argvars, typval_T *rettv);
 static void f_test_autochdir(typval_T *argvars, typval_T *rettv);
 static void f_test_disable_char_avail(typval_T *argvars, typval_T *rettv);
 static void f_test_garbagecollect_now(typval_T *argvars, typval_T *rettv);
+static void f_test_ignore_error(typval_T *argvars, typval_T *rettv);
 #ifdef FEAT_JOB_CHANNEL
 static void f_test_null_channel(typval_T *argvars, typval_T *rettv);
 #endif
@@ -823,6 +824,7 @@ static struct fst
     {"test_autochdir", 0, 0, f_test_autochdir},
     {"test_disable_char_avail", 1, 1, f_test_disable_char_avail},
     {"test_garbagecollect_now",        0, 0, f_test_garbagecollect_now},
+    {"test_ignore_error",      1, 1, f_test_ignore_error},
 #ifdef FEAT_JOB_CHANNEL
     {"test_null_channel", 0, 0, f_test_null_channel},
 #endif
@@ -12325,6 +12327,15 @@ f_test_garbagecollect_now(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
     garbage_collect(TRUE);
 }
 
+/*
+ * "test_ignore_error()" function
+ */
+    static void
+f_test_ignore_error(typval_T *argvars, typval_T *rettv UNUSED)
+{
+     ignore_error_for_testing(get_tv_string(&argvars[0]));
+}
+
 #ifdef FEAT_JOB_CHANNEL
     static void
 f_test_null_channel(typval_T *argvars UNUSED, typval_T *rettv)
index 2982a4051ed24f1039601db2b06965f34f1bbfbb..985e1ebbf2fc24473dea1462d2496a32e9c699f8 100644 (file)
@@ -539,6 +539,31 @@ emsg_not_now(void)
     return FALSE;
 }
 
+#ifdef FEAT_EVAL
+static garray_T ignore_error_list = GA_EMPTY;
+
+    void
+ignore_error_for_testing(char_u *error)
+{
+    if (ignore_error_list.ga_itemsize == 0)
+       ga_init2(&ignore_error_list, sizeof(char_u *), 1);
+
+    ga_add_string(&ignore_error_list, error);
+}
+
+    static int
+ignore_error(char_u *msg)
+{
+    int i;
+
+    for (i = 0; i < ignore_error_list.ga_len; ++i)
+       if (strstr((char *)msg,
+                 (char *)((char_u **)(ignore_error_list.ga_data))[i]) != NULL)
+           return TRUE;
+    return FALSE;
+}
+#endif
+
 #if !defined(HAVE_STRERROR) || defined(PROTO)
 /*
  * Replacement for perror() that behaves more or less like emsg() was called.
@@ -577,6 +602,12 @@ emsg(char_u *s)
     if (emsg_not_now())
        return TRUE;
 
+#ifdef FEAT_EVAL
+    /* When testing some errors are turned into a normal message. */
+    if (ignore_error(s))
+       return msg(s);
+#endif
+
     called_emsg = TRUE;
 
     /*
index c9d62c66e0fad7d6bdcbadc03f98227aecfcc9ef..9a79f14a6061b138e2e04af2f5b7d11da2e6f042 100644 (file)
@@ -8,6 +8,7 @@ void trunc_string(char_u *s, char_u *buf, int room_in, int buflen);
 void reset_last_sourcing(void);
 void msg_source(int attr);
 int emsg_not_now(void);
+void ignore_error_for_testing(char_u *error);
 void do_perror(char *msg);
 int emsg(char_u *s);
 int emsg2(char_u *s, char_u *a1);
index 77e4f2e9a6cc169ee3b0560667006076f6e966d9..6c9722dacf8148f9657bdd0c3eab405ac5c1d815 100644 (file)
@@ -17,6 +17,9 @@ endfunc
 " Test for resetting "secure" flag after GUI has started.
 " Must be run first.
 func Test_1_set_secure()
+  " Ignore the "failed to create input context" error.
+  call test_ignore_error('E285')
+
   set exrc secure
   gui -f
   call assert_equal(1, has('gui_running'))
index d4d27ecfc562779e313d3438b729d183ca33330e..e0ec0cec6826202128474bf5317351cb4a74e18b 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    392,
 /**/
     391,
 /**/