mirror of
https://github.com/neovim/neovim.git
synced 2024-12-27 14:21:31 -07:00
8f06520594
Problem:
1. Log messages (especially in CI) are hard to correlate with tests.
2. Since b353a5c05f
#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
41 lines
1.1 KiB
Lua
41 lines
1.1 KiB
Lua
-- Modules loaded here will NOT be cleared and reloaded by Busted.
|
|
-- Busted started doing this to help provide more isolation. See issue #62
|
|
-- for more information about this.
|
|
local helpers = require('test.functional.helpers')(nil)
|
|
local iswin = helpers.iswin
|
|
local busted = require("busted")
|
|
|
|
if iswin() then
|
|
local ffi = require('ffi')
|
|
ffi.cdef[[
|
|
typedef int errno_t;
|
|
errno_t _set_fmode(int mode);
|
|
]]
|
|
ffi.C._set_fmode(0x8000)
|
|
end
|
|
|
|
local testid = (function()
|
|
local id = 0
|
|
return (function()
|
|
id = id + 1
|
|
return id
|
|
end)
|
|
end)()
|
|
|
|
-- Global before_each. https://github.com/Olivine-Labs/busted/issues/613
|
|
local function before_each(_element, _parent)
|
|
local id = ('T%d'):format(testid())
|
|
_G._nvim_test_id = id
|
|
return nil, true
|
|
end
|
|
busted.subscribe({ 'test', 'start' },
|
|
before_each,
|
|
{
|
|
-- Ensure our --helper is handled before --output (see busted/runner.lua).
|
|
priority = 1,
|
|
-- Don't generate a test-id for skipped tests. /shrug
|
|
predicate = function (element, _, status)
|
|
return not ((element.descriptor == 'pending' or status == 'pending'))
|
|
end
|
|
})
|