diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2021-09-19 02:29:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-19 02:29:37 -0700 |
commit | 2afbce7651f79b0626ebeae3688274ce18ac2920 (patch) | |
tree | cb1e074962bdfc8ed00bf68775fc1fa0dbca6214 /test/functional/core/exit_spec.lua | |
parent | 924e8e4f2d88ee5c45e521e9f758b7c9f247a011 (diff) | |
download | rneovim-2afbce7651f79b0626ebeae3688274ce18ac2920.tar.gz rneovim-2afbce7651f79b0626ebeae3688274ce18ac2920.tar.bz2 rneovim-2afbce7651f79b0626ebeae3688274ce18ac2920.zip |
refactor(tests): remove redir_exec #15718
Problem
- `redir_exec` is obsolete, but it keeps getting used in new tests
because people copy existing tests.
- Disadvantages of `redir_exec`:
- Captures extra junk before the actual error/message that we _want_ to test.
- Does not fail on error, unlike e.g. `command()`.
Solution
- Use new functions like `nvim_exec` and `pcall_err`.
Diffstat (limited to 'test/functional/core/exit_spec.lua')
-rw-r--r-- | test/functional/core/exit_spec.lua | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/test/functional/core/exit_spec.lua b/test/functional/core/exit_spec.lua index 5e569a01d6..a47e7568a9 100644 --- a/test/functional/core/exit_spec.lua +++ b/test/functional/core/exit_spec.lua @@ -8,7 +8,8 @@ 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 pcall_err = helpers.pcall_err +local exec_capture = helpers.exec_capture local poke_eventloop = helpers.poke_eventloop describe('v:exiting', function() @@ -52,7 +53,7 @@ end) describe(':cquit', function() local function test_cq(cmdline, exit_code, redir_msg) if redir_msg then - eq('\n' .. redir_msg, redir_exec(cmdline)) + eq(redir_msg, pcall_err(function() return exec_capture(cmdline) end)) poke_eventloop() assert_alive() else @@ -86,14 +87,14 @@ describe(':cquit', function() 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') + test_cq('cquit 1 2', nil, 'Vim(cquit):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') + test_cq('cquit X', nil, 'Vim(cquit):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') + test_cq('cquit -1', nil, 'Vim(cquit):E488: Trailing characters: cquit -1') end) end) |