diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-05-07 22:10:50 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-05-07 22:10:50 +0200 |
commit | ba9ea91beb8f687b0f61b28319c1dbdced2f46ca (patch) | |
tree | 34c50c15c94aa61ddacca08581143b67799dd2d1 | |
parent | 1063f3d2008f22d02ccfa9dab83a23db52febbdc (diff) | |
download | vim-git-ba9ea91beb8f687b0f61b28319c1dbdced2f46ca.tar.gz |
patch 8.1.1292: invalid command line arguments not testedv8.1.1292
Problem: Invalid command line arguments not tested.
Solution: Add a test. (Dominique Pelle, closes #4346)
-rw-r--r-- | src/testdir/test_startup.vim | 90 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 92 insertions, 0 deletions
diff --git a/src/testdir/test_startup.vim b/src/testdir/test_startup.vim index 6509c0cc1..dec485b13 100644 --- a/src/testdir/test_startup.vim +++ b/src/testdir/test_startup.vim @@ -385,6 +385,96 @@ func Test_A_F_H_arg() call delete('Xtestout') endfunc +func Test_invalid_args() + if !has('unix') || has('gui_running') + " can't get output of Vim. + return + endif + + for opt in ['-Y', '--does-not-exist'] + let out = split(system(GetVimCommand() .. ' ' .. opt), "\n") + call assert_equal(1, v:shell_error) + call assert_match('^VIM - Vi IMproved .* (.*)$', out[0]) + call assert_equal('Unknown option argument: "' .. opt .. '"', out[1]) + call assert_equal('More info with: "vim -h"', out[2]) + endfor + + for opt in ['-c', '-i', '-s', '-t', '-T', '-u', '-U', '-w', '-W', '--cmd', '--startuptime'] + let out = split(system(GetVimCommand() .. ' ' .. opt), "\n") + call assert_equal(1, v:shell_error) + call assert_match('^VIM - Vi IMproved .* (.*)$', out[0]) + call assert_equal('Argument missing after: "' .. opt .. '"', out[1]) + call assert_equal('More info with: "vim -h"', out[2]) + endfor + + if has('clientserver') + " FIXME: need to add --servername to this list + " but it causes vim-8.1.1282 to crash! + for opt in ['--remote', '--remote-send', '--remote-silent', '--remote-expr', + \ '--remote-tab', '--remote-tab-wait', + \ '--remote-tab-wait-silent', '--remote-tab-silent', + \ '--remote-wait', '--remote-wait-silent', + \ ] + let out = split(system(GetVimCommand() .. ' ' .. opt), "\n") + call assert_equal(1, v:shell_error) + call assert_match('^VIM - Vi IMproved .* (.*)$', out[0]) + call assert_equal('Argument missing after: "' .. opt .. '"', out[1]) + call assert_equal('More info with: "vim -h"', out[2]) + endfor + endif + + " FIXME: commented out as this causes vim-8.1.1282 to crash! + "if has('clipboard') + " let out = split(system(GetVimCommand() .. ' --display'), "\n") + " call assert_equal(1, v:shell_error) + " call assert_match('^VIM - Vi IMproved .* (.*)$', out[0]) + " call assert_equal('Argument missing after: "--display"', out[1]) + " call assert_equal('More info with: "vim -h"', out[2]) + "endif + + let out = split(system(GetVimCommand() .. ' -ix'), "\n") + call assert_equal(1, v:shell_error) + call assert_match('^VIM - Vi IMproved .* (.*)$', out[0]) + call assert_equal('Garbage after option argument: "-ix"', out[1]) + call assert_equal('More info with: "vim -h"', out[2]) + + let out = split(system(GetVimCommand() .. ' - xxx'), "\n") + call assert_equal(1, v:shell_error) + call assert_match('^VIM - Vi IMproved .* (.*)$', out[0]) + call assert_equal('Too many edit arguments: "xxx"', out[1]) + call assert_equal('More info with: "vim -h"', out[2]) + + " Detect invalid repeated arguments '-t foo -t foo", '-q foo -q foo'. + for opt in ['-t', '-q'] + let out = split(system(GetVimCommand() .. repeat(' ' .. opt .. ' foo', 2)), "\n") + call assert_equal(1, v:shell_error) + call assert_match('^VIM - Vi IMproved .* (.*)$', out[0]) + call assert_equal('Too many edit arguments: "' .. opt .. '"', out[1]) + call assert_equal('More info with: "vim -h"', out[2]) + endfor + + for opt in [' -cq', ' --cmd q', ' +', ' -S foo'] + let out = split(system(GetVimCommand() .. repeat(opt, 11)), "\n") + call assert_equal(1, v:shell_error) + " FIXME: The error message given by Vim is not ideal in case of repeated + " -S foo since it does not mention -S. + call assert_match('^VIM - Vi IMproved .* (.*)$', out[0]) + call assert_equal('Too many "+command", "-c command" or "--cmd command" arguments', out[1]) + call assert_equal('More info with: "vim -h"', out[2]) + endfor + + " FIXME: commented out as this causes vim-8.1.1282 to crash! + "if has('gui_gtk') + " for opt in ['--socketid x', '--socketid 0xg'] + " let out = split(system(GetVimCommand() .. ' ' .. opt), "\n") + " call assert_equal(1, v:shell_error) + " call assert_match('^VIM - Vi IMproved .* (.*)$', out[0]) + " call assert_equal('Invalid argument for: "--socketid"', out[1]) + " call assert_equal('More info with: "vim -h"', out[2]) + " endfor + "endif +endfunc + func Test_file_args() let after = [ \ 'call writefile(argv(), "Xtestout")', diff --git a/src/version.c b/src/version.c index 09bb1be85..5eeec1ce1 100644 --- a/src/version.c +++ b/src/version.c @@ -768,6 +768,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1292, +/**/ 1291, /**/ 1290, |