diff options
author | Josh Leeb-du Toit <josh.leebdutoit@gmail.com> | 2017-09-29 01:12:56 +1000 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-10-22 13:02:31 +0200 |
commit | 9db42d4ce99c5b5747e9d83045b37e93d55c4249 (patch) | |
tree | 2914d827644bef6bd69ad961da686c300953bb2c /test/functional/core/exit_spec.lua | |
parent | bead15f10dbdd71c0091bbfa18ec0aab9b8b2e82 (diff) | |
download | rneovim-9db42d4ce99c5b5747e9d83045b37e93d55c4249.tar.gz rneovim-9db42d4ce99c5b5747e9d83045b37e93d55c4249.tar.bz2 rneovim-9db42d4ce99c5b5747e9d83045b37e93d55c4249.zip |
:cquit : take an error code argument #7336
closes #2699
ex_cmds.lua: use flags consistent with similar commands such as `cnext`.
upstream discussion:
"[patch] :qcuit can take exit code"
https://groups.google.com/d/msg/vim_dev/_PjyNbUKyRc/oPgr5_ZXc6AJ
Diffstat (limited to 'test/functional/core/exit_spec.lua')
-rw-r--r-- | test/functional/core/exit_spec.lua | 61 |
1 files changed, 50 insertions, 11 deletions
diff --git a/test/functional/core/exit_spec.lua b/test/functional/core/exit_spec.lua index 3fb39f3e78..188a6a2c11 100644 --- a/test/functional/core/exit_spec.lua +++ b/test/functional/core/exit_spec.lua @@ -2,8 +2,12 @@ local helpers = require('test.functional.helpers')(after_each) local command = helpers.command local eval = helpers.eval -local eq, neq = helpers.eq, helpers.neq +local eq = helpers.eq local run = helpers.run +local funcs = helpers.funcs +local nvim_prog = helpers.nvim_prog +local redir_exec = helpers.redir_exec +local wait = helpers.wait describe('v:exiting', function() local cid @@ -29,18 +33,53 @@ describe('v:exiting', function() end run(on_request, nil, on_setup) end) +end) - it('is non-zero after :cquit', function() - local function on_setup() - command('autocmd VimLeavePre * call rpcrequest('..cid..', "")') - command('autocmd VimLeave * call rpcrequest('..cid..', "")') - command('cquit') - end - local function on_request() - neq(0, eval('v:exiting')) - return '' +describe(':cquit', function() + local function test_cq(cmdline, exit_code, redir_msg) + if redir_msg then + eq('\n' .. redir_msg, redir_exec(cmdline)) + wait() + eq(2, eval("1+1")) -- Still alive? + else + funcs.system({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--headless', '--cmd', cmdline}) + eq(exit_code, eval('v:shell_error')) end - run(on_request, nil, on_setup) + end + + before_each(function() + helpers.clear() + end) + + it('exits with non-zero after :cquit', function() + test_cq('cquit', 1, nil) end) + it('exits with non-zero after :cquit 123', function() + test_cq('cquit 123', 123, nil) + end) + + it('exits with non-zero after :123 cquit', function() + test_cq('123 cquit', 123, nil) + end) + + it('exits with 0 after :cquit 0', function() + test_cq('cquit 0', 0, nil) + end) + + it('exits with 0 after :0 cquit', function() + test_cq('0 cquit', 0, nil) + end) + + it('exits with redir msg for multiple exit codes after :cquit 1 2', function() + test_cq('cquit 1 2', nil, 'E488: Trailing characters: cquit 1 2') + end) + + it('exits with redir msg for non-number exit code after :cquit X', function() + test_cq('cquit X', nil, 'E488: Trailing characters: cquit X') + end) + + it('exits with redir msg for negative exit code after :cquit -1', function() + test_cq('cquit -1', nil, 'E488: Trailing characters: cquit -1') + end) end) |