Mercurial > vim
comparison src/testdir/test_signs.vim @ 17807:b38fa4d37b7c v8.1.1900
patch 8.1.1900: sign test fails in the GUI
Commit: https://github.com/vim/vim/commit/d933c82ff4e2c910bd533ed9a50377699c3f5ec9
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Aug 21 13:45:16 2019 +0200
patch 8.1.1900: sign test fails in the GUI
Problem: Sign test fails in the GUI.
Solution: Catch and ignore the exception.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 21 Aug 2019 14:00:04 +0200 |
parents | 313f498c646e |
children | ea916dbbb9b9 |
comparison
equal
deleted
inserted
replaced
17806:4f0f9cfc8100 | 17807:b38fa4d37b7c |
---|---|
12 " Define some signs. | 12 " Define some signs. |
13 " We can specify icons even if not all versions of vim support icons as | 13 " We can specify icons even if not all versions of vim support icons as |
14 " icon is ignored when not supported. "(not supported)" is shown after | 14 " icon is ignored when not supported. "(not supported)" is shown after |
15 " the icon name when listing signs. | 15 " the icon name when listing signs. |
16 sign define Sign1 text=x | 16 sign define Sign1 text=x |
17 try | 17 |
18 sign define Sign2 text=xy texthl=Title linehl=Error | 18 call Sign_command_ignore_error('sign define Sign2 text=xy texthl=Title linehl=Error icon=../../pixmaps/stock_vim_find_help.png') |
19 \ icon=../../pixmaps/stock_vim_find_help.png | |
20 catch /E255:/ | |
21 " Ignore error: E255: Couldn't read in sign data! | |
22 " This error can happen when running in the GUI. | |
23 " Some gui like Motif do not support the png icon format. | |
24 endtry | |
25 | 19 |
26 " Test listing signs. | 20 " Test listing signs. |
27 let a=execute('sign list') | 21 let a=execute('sign list') |
28 call assert_match('^\nsign Sign1 text=x \nsign Sign2 ' . | 22 call assert_match('^\nsign Sign1 text=x \nsign Sign2 ' . |
29 \ 'icon=../../pixmaps/stock_vim_find_help.png .*text=xy ' . | 23 \ 'icon=../../pixmaps/stock_vim_find_help.png .*text=xy ' . |
101 | 95 |
102 " Check :jump with file=... | 96 " Check :jump with file=... |
103 edit foo | 97 edit foo |
104 call setline(1, ['A', 'B', 'C', 'D']) | 98 call setline(1, ['A', 'B', 'C', 'D']) |
105 | 99 |
106 try | 100 call Sign_command_ignore_error('sign define Sign3 text=y texthl=DoesNotExist linehl=DoesNotExist icon=doesnotexist.xpm') |
107 sign define Sign3 text=y texthl=DoesNotExist linehl=DoesNotExist | |
108 \ icon=doesnotexist.xpm | |
109 catch /E255:/ | |
110 " ignore error: E255: it can happens for guis. | |
111 endtry | |
112 | 101 |
113 let fn = expand('%:p') | 102 let fn = expand('%:p') |
114 exe 'sign place 43 line=2 name=Sign3 file=' . fn | 103 exe 'sign place 43 line=2 name=Sign3 file=' . fn |
115 edit bar | 104 edit bar |
116 call assert_notequal(fn, expand('%:p')) | 105 call assert_notequal(fn, expand('%:p')) |
375 call assert_fails('sign jump 61 buffer=' . bufnr, 'E934:') | 364 call assert_fails('sign jump 61 buffer=' . bufnr, 'E934:') |
376 sign unplace 61 | 365 sign unplace 61 |
377 sign undefine Sign | 366 sign undefine Sign |
378 endfunc | 367 endfunc |
379 | 368 |
369 " Ignore error: E255: Couldn't read in sign data! | |
370 " This error can happen when running in the GUI. | |
371 " Some gui like Motif do not support the png icon format. | |
372 func Sign_command_ignore_error(cmd) | |
373 try | |
374 exe a:cmd | |
375 catch /E255:/ | |
376 endtry | |
377 endfunc | |
378 | |
379 " ignore error: E255: Couldn't read in sign data! | |
380 " This error can happen when running in gui. | |
381 func Sign_define_ignore_error(name, attr) | |
382 try | |
383 call sign_define(a:name, a:attr) | |
384 catch /E255:/ | |
385 endtry | |
386 endfunc | |
387 | |
380 " Test for Vim script functions for managing signs | 388 " Test for Vim script functions for managing signs |
381 func Test_sign_funcs() | 389 func Test_sign_funcs() |
382 " Remove all the signs | 390 " Remove all the signs |
383 call sign_unplace('*') | 391 call sign_unplace('*') |
384 call sign_undefine() | 392 call sign_undefine() |
391 | 399 |
392 " Define a new sign without attributes and then update it | 400 " Define a new sign without attributes and then update it |
393 call sign_define("sign2") | 401 call sign_define("sign2") |
394 let attr = {'text' : '!!', 'linehl' : 'DiffAdd', 'texthl' : 'DiffChange', | 402 let attr = {'text' : '!!', 'linehl' : 'DiffAdd', 'texthl' : 'DiffChange', |
395 \ 'icon' : 'sign2.ico'} | 403 \ 'icon' : 'sign2.ico'} |
396 try | 404 call Sign_define_ignore_error("sign2", attr) |
397 call sign_define("sign2", attr) | |
398 catch /E255:/ | |
399 " ignore error: E255: Couldn't read in sign data! | |
400 " This error can happen when running in gui. | |
401 endtry | |
402 call assert_equal([{'name' : 'sign2', 'texthl' : 'DiffChange', | 405 call assert_equal([{'name' : 'sign2', 'texthl' : 'DiffChange', |
403 \ 'linehl' : 'DiffAdd', 'text' : '!!', 'icon' : 'sign2.ico'}], | 406 \ 'linehl' : 'DiffAdd', 'text' : '!!', 'icon' : 'sign2.ico'}], |
404 \ sign_getdefined("sign2")) | 407 \ sign_getdefined("sign2")) |
405 | 408 |
406 " Test for a sign name with digits | 409 " Test for a sign name with digits |
516 call assert_equal([], sign_getdefined("sign1")) | 519 call assert_equal([], sign_getdefined("sign1")) |
517 call assert_fails('call sign_undefine("none")', 'E155:') | 520 call assert_fails('call sign_undefine("none")', 'E155:') |
518 call assert_fails('call sign_undefine({})', 'E731:') | 521 call assert_fails('call sign_undefine({})', 'E731:') |
519 | 522 |
520 " Test for using '.' as the line number for sign_place() | 523 " Test for using '.' as the line number for sign_place() |
521 call sign_define("sign1", attr) | 524 call Sign_define_ignore_error("sign1", attr) |
522 call cursor(22, 1) | 525 call cursor(22, 1) |
523 call assert_equal(15, sign_place(15, '', 'sign1', 'Xsign', | 526 call assert_equal(15, sign_place(15, '', 'sign1', 'Xsign', |
524 \ {'lnum' : '.'})) | 527 \ {'lnum' : '.'})) |
525 call assert_equal([{'bufnr' : bufnr(''), 'signs' : | 528 call assert_equal([{'bufnr' : bufnr(''), 'signs' : |
526 \ [{'id' : 15, 'group' : '', 'lnum' : 22, 'name' : 'sign1', | 529 \ [{'id' : 15, 'group' : '', 'lnum' : 22, 'name' : 'sign1', |