Mercurial > vim
comparison src/testdir/test_startup.vim @ 24126:51ba4b49d7f9 v8.2.2604
patch 8.2.2604: GUI-specific command line arguments not tested
Commit: https://github.com/vim/vim/commit/240309c9bfa8a0d2f154712f8e0dd33589f181d3
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 14 16:20:37 2021 +0100
patch 8.2.2604: GUI-specific command line arguments not tested
Problem: GUI-specific command line arguments not tested.
Solution: Add tests for several arguments. (Dominique Pell?, closes https://github.com/vim/vim/issues/7962)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 14 Mar 2021 16:30:02 +0100 |
parents | e310c2a0bb8c |
children | 9433e10ce242 |
comparison
equal
deleted
inserted
replaced
24125:b616f39b8989 | 24126:51ba4b49d7f9 |
---|---|
107 call delete('Xtestout') | 107 call delete('Xtestout') |
108 call delete('Xhere', 'rf') | 108 call delete('Xhere', 'rf') |
109 endfunc | 109 endfunc |
110 | 110 |
111 func Test_help_arg() | 111 func Test_help_arg() |
112 if !has('unix') && has('gui_running') | 112 CheckNotMSWindows |
113 throw 'Skipped: does not work with gvim on MS-Windows' | 113 |
114 endif | |
115 if RunVim([], [], '--help >Xtestout') | 114 if RunVim([], [], '--help >Xtestout') |
116 let lines = readfile('Xtestout') | 115 let lines = readfile('Xtestout') |
117 call assert_true(len(lines) > 20) | 116 call assert_true(len(lines) > 20) |
118 call assert_match('Vi IMproved', lines[0]) | 117 call assert_match('Vi IMproved', lines[0]) |
119 | 118 |
405 call assert_equal(['1', '0', '0', '1'], lines) | 404 call assert_equal(['1', '0', '0', '1'], lines) |
406 endif | 405 endif |
407 | 406 |
408 call delete('Xtestout') | 407 call delete('Xtestout') |
409 endfunc | 408 endfunc |
409 | |
410 " Test the --echo-wid argument (for GTK GUI only). | |
411 func Test_echo_wid() | |
412 CheckCanRunGui | |
413 CheckFeature gui_gtk | |
414 | |
415 if RunVim([], [], '-g --echo-wid -cq >Xtest_echo_wid') | |
416 let lines = readfile('Xtest_echo_wid') | |
417 call assert_equal(1, len(lines)) | |
418 call assert_match('^WID: \d\+$', lines[0]) | |
419 endif | |
420 | |
421 call delete('Xtest_echo_wid') | |
422 endfunction | |
423 | |
424 " Test the -reverse and +reverse arguments (for GUI only). | |
425 func Test_reverse() | |
426 CheckCanRunGui | |
427 CheckNotMSWindows | |
428 | |
429 let after =<< trim [CODE] | |
430 call writefile([&background], "Xtest_reverse") | |
431 qall | |
432 [CODE] | |
433 if RunVim([], after, '-f -g -reverse') | |
434 let lines = readfile('Xtest_reverse') | |
435 call assert_equal(['dark'], lines) | |
436 endif | |
437 if RunVim([], after, '-f -g +reverse') | |
438 let lines = readfile('Xtest_reverse') | |
439 call assert_equal(['light'], lines) | |
440 endif | |
441 | |
442 call delete('Xtest_reverse') | |
443 endfunc | |
444 | |
445 " Test the -background and -foreground arguments (for GUI only). | |
446 func Test_background_foreground() | |
447 CheckCanRunGui | |
448 CheckNotMSWindows | |
449 | |
450 " Is there a better way to check the effect of -background & -foreground | |
451 " other than merely looking at &background (dark or light)? | |
452 let after =<< trim [CODE] | |
453 call writefile([&background], "Xtest_fg_bg") | |
454 qall | |
455 [CODE] | |
456 if RunVim([], after, '-f -g -background darkred -foreground yellow') | |
457 let lines = readfile('Xtest_fg_bg') | |
458 call assert_equal(['dark'], lines) | |
459 endif | |
460 if RunVim([], after, '-f -g -background ivory -foreground darkgreen') | |
461 let lines = readfile('Xtest_fg_bg') | |
462 call assert_equal(['light'], lines) | |
463 endif | |
464 | |
465 call delete('Xtest_fg_bg') | |
466 endfunc | |
467 | |
468 " Test the -font argument (for GUI only). | |
469 func Test_font() | |
470 CheckCanRunGui | |
471 CheckNotMSWindows | |
472 | |
473 if has('gui_gtk') | |
474 let font = 'Courier 14' | |
475 elseif has('gui_motif') || has('gui_athena') | |
476 let font = '-misc-fixed-bold-*' | |
477 else | |
478 throw 'Skipped: test does not set a valid font for this GUI' | |
479 endif | |
480 | |
481 let after =<< trim [CODE] | |
482 call writefile([&guifont], "Xtest_font") | |
483 qall | |
484 [CODE] | |
485 | |
486 if RunVim([], after, '--nofork -g -font "' .. font .. '"') | |
487 let lines = readfile('Xtest_font') | |
488 call assert_equal([font], lines) | |
489 endif | |
490 | |
491 call delete('Xtest_font') | |
492 endfunc | |
493 | |
494 " Test the -geometry argument (for GUI only). | |
495 func Test_geometry() | |
496 CheckCanRunGui | |
497 CheckNotMSWindows | |
498 | |
499 if has('gui_motif') || has('gui_athena') | |
500 " FIXME: With GUI Athena or Motif, the value of getwinposx(), | |
501 " getwinposy() and getwinpos() do not match exactly the | |
502 " value given in -geometry. Why? | |
503 " So only check &columns and &lines for those GUIs. | |
504 let after =<< trim [CODE] | |
505 call writefile([&columns, &lines], "Xtest_geometry") | |
506 qall | |
507 [CODE] | |
508 if RunVim([], after, '-f -g -geometry 31x13+41+43') | |
509 let lines = readfile('Xtest_geometry') | |
510 call assert_equal(['31', '13'], lines) | |
511 endif | |
512 else | |
513 let after =<< trim [CODE] | |
514 call writefile([&columns, &lines, getwinposx(), getwinposy(), string(getwinpos())], "Xtest_geometry") | |
515 qall | |
516 [CODE] | |
517 if RunVim([], after, '-f -g -geometry 31x13+41+43') | |
518 let lines = readfile('Xtest_geometry') | |
519 call assert_equal(['31', '13', '41', '43', '[41, 43]'], lines) | |
520 endif | |
521 endif | |
522 | |
523 call delete('Xtest_geometry') | |
524 endfunc | |
525 | |
526 " Test the -iconic argument (for GUI only). | |
527 func Test_iconic() | |
528 CheckCanRunGui | |
529 CheckNotMSWindows | |
530 | |
531 call RunVim([], [], '-f -g -iconic -cq') | |
532 | |
533 " TODO: currently only start vim iconified, but does not | |
534 " check that vim is iconified. How could this be checked? | |
535 endfunc | |
536 | |
410 | 537 |
411 func Test_invalid_args() | 538 func Test_invalid_args() |
412 " must be able to get the output of Vim. | 539 " must be able to get the output of Vim. |
413 CheckUnix | 540 CheckUnix |
414 CheckNotGui | 541 CheckNotGui |
1040 let prognames = ['vim', 'gvim', 'ex', 'exim', 'view', 'gview', | 1167 let prognames = ['vim', 'gvim', 'ex', 'exim', 'view', 'gview', |
1041 \ 'evim', 'eview', 'rvim', 'rgvim', 'rview', 'rgview', | 1168 \ 'evim', 'eview', 'rvim', 'rgvim', 'rview', 'rgview', |
1042 \ 'vimdiff', 'gvimdiff'] | 1169 \ 'vimdiff', 'gvimdiff'] |
1043 | 1170 |
1044 for progname in prognames | 1171 for progname in prognames |
1045 if empty($DISPLAY) | 1172 let run_with_gui = (progname =~# 'g') || (has('gui') && (progname ==# 'evim' || progname ==# 'eview')) |
1046 if progname =~# 'g' | 1173 |
1047 " Can't run gvim, gview (etc.) if $DISPLAY is not setup. | 1174 if empty($DISPLAY) && run_with_gui |
1048 continue | 1175 " Can't run gvim, gview (etc.) if $DISPLAY is not setup. |
1049 endif | 1176 continue |
1050 if has('gui') && (progname ==# 'evim' || progname ==# 'eview') | |
1051 " evim or eview will start the GUI if there is gui support. | |
1052 " So don't try to start them either if $DISPLAY is not setup. | |
1053 continue | |
1054 endif | |
1055 endif | 1177 endif |
1056 | 1178 |
1057 exe 'silent !ln -s -f ' ..exepath(GetVimProg()) .. ' Xprogname/' .. progname | 1179 exe 'silent !ln -s -f ' ..exepath(GetVimProg()) .. ' Xprogname/' .. progname |
1058 | 1180 |
1059 let stdout_stderr = '' | 1181 let stdout_stderr = '' |
1064 endif | 1186 endif |
1065 | 1187 |
1066 if progname =~# 'g' && !has('gui') | 1188 if progname =~# 'g' && !has('gui') |
1067 call assert_equal("E25: GUI cannot be used: Not enabled at compile time\n", stdout_stderr, progname) | 1189 call assert_equal("E25: GUI cannot be used: Not enabled at compile time\n", stdout_stderr, progname) |
1068 else | 1190 else |
1069 call assert_equal('', stdout_stderr, progname) | 1191 " GUI motif can output some warnings like this: |
1192 " Warning: | |
1193 " Name: subMenu | |
1194 " Class: XmCascadeButton | |
1195 " Illegal mnemonic character; Could not convert X KEYSYM to a keycode | |
1196 " So don't check that stderr is empty with GUI Motif. | |
1197 if run_with_gui && !has('gui_motif') | |
1198 call assert_equal('', stdout_stderr, progname) | |
1199 endif | |
1070 call assert_equal(expectations[progname], readfile('Xprogname_out'), progname) | 1200 call assert_equal(expectations[progname], readfile('Xprogname_out'), progname) |
1071 endif | 1201 endif |
1072 | 1202 |
1073 call delete('Xprogname/' .. progname) | 1203 call delete('Xprogname/' .. progname) |
1074 call delete('Xprogname_out') | 1204 call delete('Xprogname_out') |