aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2020-02-16 19:02:09 -0800
committerJustin M. Keyes <justinkz@gmail.com>2020-02-16 22:09:28 -0800
commit6e13b9d26134210f0963341bd77c64a4437f37ec (patch)
tree5d94ed3b0b007f4cd966d956f5cde241a8735b83 /test/functional
parenta446fbc8fa278d9c1e4144dc9767c9dc0b184583 (diff)
downloadrneovim-6e13b9d26134210f0963341bd77c64a4437f37ec.tar.gz
rneovim-6e13b9d26134210f0963341bd77c64a4437f37ec.tar.bz2
rneovim-6e13b9d26134210f0963341bd77c64a4437f37ec.zip
test/LSP: assert contents of log file
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/fixtures/fake-lsp-server.lua14
-rw-r--r--test/functional/plugin/lsp_spec.lua4
2 files changed, 16 insertions, 2 deletions
diff --git a/test/functional/fixtures/fake-lsp-server.lua b/test/functional/fixtures/fake-lsp-server.lua
index cac590fd14..dca7f35923 100644
--- a/test/functional/fixtures/fake-lsp-server.lua
+++ b/test/functional/fixtures/fake-lsp-server.lua
@@ -1,6 +1,16 @@
local protocol = require 'vim.lsp.protocol'
+-- Logs to $NVIM_LOG_FILE.
+--
+-- TODO(justinmk): remove after https://github.com/neovim/neovim/pull/7062
+local function log(loglevel, area, msg)
+ vim.fn.writefile(
+ {string.format('%s %s: %s', loglevel, area, msg)},
+ vim.env.NVIM_LOG_FILE,
+ 'a')
+end
+
local function message_parts(sep, ...)
local parts = {}
for i = 1, select("#", ...) do
@@ -422,7 +432,7 @@ local kill_timer = vim.loop.new_timer()
kill_timer:start(_G.TIMEOUT or 1e3, 0, function()
kill_timer:stop()
kill_timer:close()
- -- TODO: log('TIMEOUT')
+ log('ERROR', 'LSP', 'TIMEOUT')
io.stderr:write("TIMEOUT")
os.exit(100)
end)
@@ -433,7 +443,7 @@ local status, err = pcall(assert(tests[test_name], "Test not found"))
kill_timer:stop()
kill_timer:close()
if not status then
- -- TODO: log(err)
+ log('ERROR', 'LSP', tostring(err))
io.stderr:write(err)
os.exit(101)
end
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index b2d00a400a..03e516d6f6 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -1,11 +1,13 @@
local helpers = require('test.functional.helpers')(after_each)
+local assert_log = helpers.assert_log
local clear = helpers.clear
local buf_lines = helpers.buf_lines
local dedent = helpers.dedent
local exec_lua = helpers.exec_lua
local eq = helpers.eq
local eq_dumplog = helpers.eq_dumplog
+local pesc = helpers.pesc
local insert = helpers.insert
local retry = helpers.retry
local NIL = helpers.NIL
@@ -229,6 +231,8 @@ describe('LSP', function()
on_exit = function(code, signal)
eq_dumplog(fake_lsp_logfile, 101, code, "exit code") -- See fake-lsp-server.lua
eq_dumplog(fake_lsp_logfile, 0, signal, "exit signal")
+ assert_log(pesc([[assert_eq failed: left == "\"shutdown\"", right == "\"test\""]]),
+ fake_lsp_logfile)
end;
on_callback = function(...)
eq(table.remove(expected_callbacks), {...}, "expected callback")