diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2022-05-23 21:44:15 -0700 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2022-06-15 19:23:10 -0700 |
commit | 8f065205946844d87f00d6c55517521e3809f821 (patch) | |
tree | 7201a15d3b8f8992fc67a3769ffb6ad06657b9d4 /test/helpers.lua | |
parent | fa4b0c3ba5c4aa6dce90cf9d5fb63ea65fd0daee (diff) | |
download | rneovim-8f065205946844d87f00d6c55517521e3809f821.tar.gz rneovim-8f065205946844d87f00d6c55517521e3809f821.tar.bz2 rneovim-8f065205946844d87f00d6c55517521e3809f821.zip |
feat(logging): include test-id in log messages
Problem:
1. Log messages (especially in CI) are hard to correlate with tests.
2. Since b353a5c05f02 #11886, dumplog() prints the logs next to test
failures. This is noisy and gets in the way of the test results.
Solution:
1. Associate an incrementing id with each test and include it in log
messages.
- FUTURE: add v:name so Nvim instances can be formally "named"?
2. Mention "child" in log messages if the current Nvim is a child (based
on the presence of $NVIM).
BEFORE:
DBG … 12345 UI: event
DBG … 12345 log_server_msg:722: RPC ->ch 1: …
DBG … 12345 UI: flush
DBG … 12345 inbuf_poll:444: blocking... events_enabled=1 events_pending=0
DBG … 23454 UI: stop
INF … 23454 os_exit:594: Nvim exit: 0
AFTER:
DBG … T57 UI: event
DBG … T57 log_server_msg:722: RPC ->ch 1: …
DBG … T57 UI: flush
DBG … T57 inbuf_poll:444: blocking... events_enabled=1 events_pending=0
DBG … T57/child UI: stop
INF … T57/child os_exit:594: Nvim exit: 0
Diffstat (limited to 'test/helpers.lua')
-rw-r--r-- | test/helpers.lua | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/test/helpers.lua b/test/helpers.lua index 7d2f8f760a..f37af9d08d 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -40,10 +40,6 @@ function module.popen_r(...) return io.popen(module.argss_to_cmd(...), 'r') end -function module.popen_w(...) - return io.popen(module.argss_to_cmd(...), 'w') -end - -- sleeps the test runner (_not_ the nvim instance) function module.sleep(ms) luv.sleep(ms) @@ -104,16 +100,16 @@ end --- ---@param pat string Lua pattern to search for in the log file ---@param logfile string Full path to log file (default=$NVIM_LOG_FILE) -function module.assert_log(pat, logfile) +---@param nrlines number Search up to this many log lines +function module.assert_log(pat, logfile, nrlines) logfile = logfile or os.getenv('NVIM_LOG_FILE') or '.nvimlog' - local nrlines = 10 + nrlines = nrlines or 10 local lines = module.read_file_list(logfile, -nrlines) or {} for _,line in ipairs(lines) do if line:match(pat) then return end end - local logtail = module.read_nvim_log(logfile) error(string.format('Pattern %q not found in log (last %d lines): %s:\n%s', - pat, nrlines, logfile, logtail)) + pat, nrlines, logfile, ' '..table.concat(lines, '\n '))) end -- Invokes `fn` and returns the error string (with truncated paths), or raises @@ -271,7 +267,7 @@ module.uname = (function() return platform end - if os.getenv("SYSTEM_NAME") then -- From CMAKE_SYSTEM_NAME. + if os.getenv("SYSTEM_NAME") then -- From CMAKE_HOST_SYSTEM_NAME. platform = string.lower(os.getenv("SYSTEM_NAME")) return platform end @@ -409,17 +405,6 @@ function module.check_cores(app, force) end end -function module.which(exe) - local pipe = module.popen_r('which', exe) - local ret = pipe:read('*a') - pipe:close() - if ret == '' then - return nil - else - return ret:sub(1, -2) - end -end - function module.repeated_read_cmd(...) for _ = 1, 10 do local stream = module.popen_r(...) |