diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2020-02-08 18:08:02 -0800 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2020-02-16 19:04:40 -0800 |
commit | 4cf48dc329e3e3f451ecf902af9af6317d44bb40 (patch) | |
tree | 19ec81eb39c3b760e519e9fb15e234255d37a4c8 /test/helpers.lua | |
parent | 1eb0f5371ae8cee90b97f586a99505cfa5913504 (diff) | |
download | rneovim-4cf48dc329e3e3f451ecf902af9af6317d44bb40.tar.gz rneovim-4cf48dc329e3e3f451ecf902af9af6317d44bb40.tar.bz2 rneovim-4cf48dc329e3e3f451ecf902af9af6317d44bb40.zip |
test/LSP: dump logs on error
This will help debug CI flakey failures.
TODO: helpers.assert_log() -- Explicitly check contents of the logfile.
Diffstat (limited to 'test/helpers.lua')
-rw-r--r-- | test/helpers.lua | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/test/helpers.lua b/test/helpers.lua index 98f003f208..d9e1f4a963 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -58,6 +58,14 @@ local check_logs_useless_lines = { function module.eq(expected, actual, context) return assert.are.same(expected, actual, context) end +-- Like eq(), but includes tail of `logfile` in failure message. +function module.eq_dumplog(logfile, expected, actual, context) + local status, rv = pcall(module.eq, expected, actual, context) + if not status then + local logtail = module.read_nvim_log(logfile) + error(string.format('%s\n%s', rv, logtail)) + end +end function module.neq(expected, actual, context) return assert.are_not.same(expected, actual, context) end @@ -737,10 +745,10 @@ function module.isCI(name) end --- Gets the contents of $NVIM_LOG_FILE for printing to the build log. +-- Gets the contents of `logfile` for printing to the build log. -- Also moves the file to "${NVIM_LOG_FILE}.displayed" on CI environments. -function module.read_nvim_log() - local logfile = os.getenv('NVIM_LOG_FILE') or '.nvimlog' +function module.read_nvim_log(logfile) + logfile = logfile or os.getenv('NVIM_LOG_FILE') or '.nvimlog' local is_ci = module.isCI() local keep = is_ci and 999 or 10 local lines = module.read_file_list(logfile, -keep) or {} |