mirror of
https://github.com/neovim/neovim.git
synced 2026-07-14 21:30:34 +00:00
feat(logging): rename ".nvimlog" => "nvim.log" #37935
- Rename ".nvimlog" to "nvim.log" - doesn't need to be "hidden"/dotfile - ".log" extension helps with filetype detection - Also rename "nvim/log" => "nvim/nvim.log"
This commit is contained in:
3
.github/workflows/test.yml
vendored
3
.github/workflows/test.yml
vendored
@@ -20,7 +20,7 @@ env:
|
|||||||
BUILD_DIR: ${{ github.workspace }}/build
|
BUILD_DIR: ${{ github.workspace }}/build
|
||||||
INSTALL_PREFIX: ${{ github.workspace }}/nvim-install
|
INSTALL_PREFIX: ${{ github.workspace }}/nvim-install
|
||||||
LOG_DIR: ${{ github.workspace }}/build/log
|
LOG_DIR: ${{ github.workspace }}/build/log
|
||||||
NVIM_LOG_FILE: ${{ github.workspace }}/build/.nvimlog
|
NVIM_LOG_FILE: ${{ github.workspace }}/build/nvim.log
|
||||||
TSAN_OPTIONS: log_path=${{ github.workspace }}/build/log/tsan
|
TSAN_OPTIONS: log_path=${{ github.workspace }}/build/log/tsan
|
||||||
VALGRIND_LOG: ${{ github.workspace }}/build/log/valgrind-%p.log
|
VALGRIND_LOG: ${{ github.workspace }}/build/log/valgrind-%p.log
|
||||||
# TEST_FILE: test/functional/core/startup_spec.lua
|
# TEST_FILE: test/functional/core/startup_spec.lua
|
||||||
@@ -176,6 +176,7 @@ jobs:
|
|||||||
TEST_TIMEOUT: 600
|
TEST_TIMEOUT: 600
|
||||||
run: |
|
run: |
|
||||||
set +e
|
set +e
|
||||||
|
# `-k 0` tells ninja to continue running all targets even if some fail.
|
||||||
cmake --build build --target functionaltest_parallel -j 2 -- -k 0
|
cmake --build build --target functionaltest_parallel -j 2 -- -k 0
|
||||||
exit_code="$?"
|
exit_code="$?"
|
||||||
cmake --build build --target functionaltest_summary
|
cmake --build build --target functionaltest_summary
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -33,9 +33,6 @@ compile_commands.json
|
|||||||
/src/nvim/po/vim.pot
|
/src/nvim/po/vim.pot
|
||||||
/src/nvim/po/*.ck
|
/src/nvim/po/*.ck
|
||||||
|
|
||||||
# Generated by tests with $NVIM_LOG_FILE set.
|
|
||||||
/.nvimlog
|
|
||||||
|
|
||||||
# Generated by scripts/vim-patch.sh
|
# Generated by scripts/vim-patch.sh
|
||||||
/.vim-src
|
/.vim-src
|
||||||
*.rej
|
*.rej
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ unset(ENV{TMUX}) # Nvim TUI shouldn't think it's running in tmux. #34173
|
|||||||
set(ENV{CIRRUS_CI} ${CIRRUS_CI})
|
set(ENV{CIRRUS_CI} ${CIRRUS_CI})
|
||||||
|
|
||||||
if(NOT DEFINED ENV{NVIM_LOG_FILE})
|
if(NOT DEFINED ENV{NVIM_LOG_FILE})
|
||||||
set(ENV{NVIM_LOG_FILE} ${BUILD_DIR}/.nvimlog)
|
set(ENV{NVIM_LOG_FILE} ${BUILD_DIR}/nvim.log)
|
||||||
endif()
|
endif()
|
||||||
set(ENV{NVIM_LOG_FILE} "$ENV{NVIM_LOG_FILE}${TEST_SUFFIX}")
|
set(ENV{NVIM_LOG_FILE} "$ENV{NVIM_LOG_FILE}${TEST_SUFFIX}")
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ see also |lua-guide|. Use any existing test as a template to start writing new
|
|||||||
tests, or see |dev-quickstart|.
|
tests, or see |dev-quickstart|.
|
||||||
|
|
||||||
Tests are run by the `/cmake/RunTests.cmake` script using `busted` (a Lua test-runner).
|
Tests are run by the `/cmake/RunTests.cmake` script using `busted` (a Lua test-runner).
|
||||||
For some failures, `.nvimlog` (or `$NVIM_LOG_FILE`) may provide insight.
|
For some failures, `./build/nvim.log` (or `$NVIM_LOG_FILE`) may provide insight.
|
||||||
|
|
||||||
Depending on the presence of binaries (e.g., `xclip`) some tests will be
|
Depending on the presence of binaries (e.g., `xclip`) some tests will be
|
||||||
skipped.
|
skipped.
|
||||||
@@ -80,6 +80,10 @@ To run only _unit_ tests: >
|
|||||||
To run only _functional_ tests: >
|
To run only _functional_ tests: >
|
||||||
make functionaltest
|
make functionaltest
|
||||||
|
|
||||||
|
To run functional tests in parallel (used in CI): >
|
||||||
|
cmake --build build --target functionaltest_parallel -j2
|
||||||
|
cmake --build build --target functionaltest_summary
|
||||||
|
|
||||||
|
|
||||||
LEGACY TESTS
|
LEGACY TESTS
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ alternate file (e.g. stderr) use `LOG_CALLSTACK_TO_FILE(FILE*)`. Requires
|
|||||||
Many log messages have a shared prefix, such as "UI" or "RPC". Use the shell to
|
Many log messages have a shared prefix, such as "UI" or "RPC". Use the shell to
|
||||||
filter the log, e.g. at DEBUG level you might want to exclude UI messages: >
|
filter the log, e.g. at DEBUG level you might want to exclude UI messages: >
|
||||||
|
|
||||||
tail -F ~/.local/state/nvim/log | cat -v | stdbuf -o0 grep -v UI | stdbuf -o0 tee -a log
|
tail -F ~/.local/state/nvim/nvim.log | cat -v | stdbuf -o0 grep -v UI | stdbuf -o0 tee -a log
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|||||||
@@ -1411,9 +1411,9 @@ CACHE DIRECTORY (DEFAULT) ~
|
|||||||
Windows: ~/AppData/Local/Temp ~/AppData/Local/Temp/nvim-data
|
Windows: ~/AppData/Local/Temp ~/AppData/Local/Temp/nvim-data
|
||||||
|
|
||||||
LOG FILE (DEFAULT) ~
|
LOG FILE (DEFAULT) ~
|
||||||
`$NVIM_LOG_FILE` Nvim: stdpath("log")/log
|
`$NVIM_LOG_FILE` Nvim: stdpath("log")/nvim.log
|
||||||
Unix: ~/.local/state/nvim ~/.local/state/nvim/log
|
Unix: ~/.local/state/nvim ~/.local/state/nvim/nvim.log
|
||||||
Windows: ~/AppData/Local/nvim-data ~/AppData/Local/nvim-data/log
|
Windows: ~/AppData/Local/nvim-data ~/AppData/Local/nvim-data/nvim.log
|
||||||
|
|
||||||
Note that stdpath("log") is currently an alias for stdpath("state").
|
Note that stdpath("log") is currently an alias for stdpath("state").
|
||||||
|
|
||||||
@@ -1453,8 +1453,8 @@ LOG FILE *log* *$NVIM_LOG_FILE* *E5430*
|
|||||||
Besides 'debug' and 'verbose', Nvim keeps a general log file for internal
|
Besides 'debug' and 'verbose', Nvim keeps a general log file for internal
|
||||||
debugging, plugins and RPC clients. >
|
debugging, plugins and RPC clients. >
|
||||||
:echo $NVIM_LOG_FILE
|
:echo $NVIM_LOG_FILE
|
||||||
By default, the file is located at stdpath("log")/log ($XDG_STATE_HOME/nvim/log)
|
Default location is stdpath("log")/log ($XDG_STATE_HOME/nvim/nvim.log) unless
|
||||||
unless that path is inaccessible or if $NVIM_LOG_FILE was set before |startup|.
|
that path is inaccessible or $NVIM_LOG_FILE was set before |startup|.
|
||||||
|
|
||||||
|
|
||||||
vim:noet:tw=78:ts=8:ft=help:norl:
|
vim:noet:tw=78:ts=8:ft=help:norl:
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ Defaults to
|
|||||||
.Ic ":help $NVIM_APPNAME"
|
.Ic ":help $NVIM_APPNAME"
|
||||||
.It Ev NVIM_LOG_FILE
|
.It Ev NVIM_LOG_FILE
|
||||||
Low-level log file, usually found at
|
Low-level log file, usually found at
|
||||||
.Pa ~/.local/state/nvim/log .
|
.Pa ~/.local/state/nvim/nvim.log .
|
||||||
.Ic ":help $NVIM_LOG_FILE"
|
.Ic ":help $NVIM_LOG_FILE"
|
||||||
.It Ev VIM
|
.It Ev VIM
|
||||||
Used to locate user files, such as init.vim.
|
Used to locate user files, such as init.vim.
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ static bool log_try_create(char *fname)
|
|||||||
|
|
||||||
/// Initializes the log file path and sets $NVIM_LOG_FILE if empty.
|
/// Initializes the log file path and sets $NVIM_LOG_FILE if empty.
|
||||||
///
|
///
|
||||||
/// Tries $NVIM_LOG_FILE, or falls back to $XDG_STATE_HOME/nvim/log. Failed
|
/// Tries $NVIM_LOG_FILE, or falls back to $XDG_STATE_HOME/nvim/nvim.log. Failed
|
||||||
/// initialization indicates either a bug in expand_env() or both $NVIM_LOG_FILE
|
/// initialization indicates either a bug in expand_env() or both $NVIM_LOG_FILE
|
||||||
/// and $HOME environment variables are undefined.
|
/// and $HOME environment variables are undefined.
|
||||||
static void log_path_init(void)
|
static void log_path_init(void)
|
||||||
@@ -78,12 +78,12 @@ static void log_path_init(void)
|
|||||||
}
|
}
|
||||||
XFREE_CLEAR(loghome);
|
XFREE_CLEAR(loghome);
|
||||||
// Invalid $NVIM_LOG_FILE or failed to expand; fall back to default.
|
// Invalid $NVIM_LOG_FILE or failed to expand; fall back to default.
|
||||||
char *defaultpath = stdpaths_user_state_subpath("log", 0, true);
|
char *defaultpath = stdpaths_user_state_subpath("nvim.log", 0, true);
|
||||||
size_t len = xstrlcpy(log_file_path, defaultpath, size);
|
size_t len = xstrlcpy(log_file_path, defaultpath, size);
|
||||||
xfree(defaultpath);
|
xfree(defaultpath);
|
||||||
// Fall back to .nvimlog
|
// Fall back to $CWD/nvim.log
|
||||||
if (len >= size || !log_try_create(log_file_path)) {
|
if (len >= size || !log_try_create(log_file_path)) {
|
||||||
len = xstrlcpy(log_file_path, ".nvimlog", size);
|
len = xstrlcpy(log_file_path, "nvim.log", size);
|
||||||
}
|
}
|
||||||
// Fall back to stderr
|
// Fall back to stderr
|
||||||
if (len >= size || !log_try_create(log_file_path)) {
|
if (len >= size || !log_try_create(log_file_path)) {
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ describe('startup defaults', function()
|
|||||||
eq('Xtest-logpath', eval('$NVIM_LOG_FILE'))
|
eq('Xtest-logpath', eval('$NVIM_LOG_FILE'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('defaults to stdpath("log")/log if empty', function()
|
it('defaults to stdpath("log")/nvim.log if empty', function()
|
||||||
eq(true, mkdir(xdgdir) and mkdir(xdgstatedir))
|
eq(true, mkdir(xdgdir) and mkdir(xdgstatedir))
|
||||||
clear({
|
clear({
|
||||||
env = {
|
env = {
|
||||||
@@ -260,10 +260,10 @@ describe('startup defaults', function()
|
|||||||
NVIM_LOG_FILE = '', -- Empty is invalid.
|
NVIM_LOG_FILE = '', -- Empty is invalid.
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
eq(xdgstatedir .. '/log', t.fix_slashes(eval('$NVIM_LOG_FILE')))
|
eq(xdgstatedir .. '/nvim.log', t.fix_slashes(eval('$NVIM_LOG_FILE')))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('defaults to stdpath("log")/log if invalid', function()
|
it('defaults to stdpath("log")/nvim.log if invalid', function()
|
||||||
eq(true, mkdir(xdgdir) and mkdir(xdgstatedir))
|
eq(true, mkdir(xdgdir) and mkdir(xdgstatedir))
|
||||||
clear({
|
clear({
|
||||||
env = {
|
env = {
|
||||||
@@ -271,7 +271,7 @@ describe('startup defaults', function()
|
|||||||
NVIM_LOG_FILE = '.', -- Any directory is invalid.
|
NVIM_LOG_FILE = '.', -- Any directory is invalid.
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
eq(xdgstatedir .. '/log', t.fix_slashes(eval('$NVIM_LOG_FILE')))
|
eq(xdgstatedir .. '/nvim.log', t.fix_slashes(eval('$NVIM_LOG_FILE')))
|
||||||
-- Avoid "failed to open $NVIM_LOG_FILE" noise in test output.
|
-- Avoid "failed to open $NVIM_LOG_FILE" noise in test output.
|
||||||
expect_exit(command, 'qall!')
|
expect_exit(command, 'qall!')
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ end
|
|||||||
--- @param fn function
|
--- @param fn function
|
||||||
--- @return any
|
--- @return any
|
||||||
function M.retry(max, max_ms, fn)
|
function M.retry(max, max_ms, fn)
|
||||||
luaassert(max == nil or max > 0)
|
assert(max == nil or max > 0)
|
||||||
luaassert(max_ms == nil or max_ms > 0)
|
assert(max_ms == nil or max_ms > 0)
|
||||||
local tries = 1
|
local tries = 1
|
||||||
local timeout = (max_ms and max_ms or 10000)
|
local timeout = (max_ms and max_ms or 10000)
|
||||||
local start_time = uv.now()
|
local start_time = uv.now()
|
||||||
@@ -112,12 +112,12 @@ end
|
|||||||
--- @param expected (any) description of expected result
|
--- @param expected (any) description of expected result
|
||||||
--- @param actual (any) description of actual result
|
--- @param actual (any) description of actual result
|
||||||
function M.ok(cond, expected, actual)
|
function M.ok(cond, expected, actual)
|
||||||
luaassert(
|
assert(
|
||||||
(not expected and not actual) or (expected and actual),
|
(not expected and not actual) or (expected and actual),
|
||||||
'if "expected" is given, "actual" is also required'
|
'if "expected" is given, "actual" is also required'
|
||||||
)
|
)
|
||||||
local msg = expected and ('expected %s, got: %s'):format(expected, tostring(actual)) or nil
|
local msg = expected and ('expected %s, got: %s'):format(expected, tostring(actual)) or nil
|
||||||
return luaassert(cond, msg)
|
return assert(cond, msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function epicfail(state, arguments, _)
|
local function epicfail(state, arguments, _)
|
||||||
@@ -151,8 +151,8 @@ end
|
|||||||
---@param nrlines? (number) Search up to this many log lines (default 10)
|
---@param nrlines? (number) Search up to this many log lines (default 10)
|
||||||
---@param inverse? (boolean) Assert that the pattern does NOT match.
|
---@param inverse? (boolean) Assert that the pattern does NOT match.
|
||||||
function M.assert_log(pat, logfile, nrlines, inverse)
|
function M.assert_log(pat, logfile, nrlines, inverse)
|
||||||
logfile = logfile or os.getenv('NVIM_LOG_FILE') or '.nvimlog'
|
logfile = logfile or os.getenv('NVIM_LOG_FILE') or 'nvim.log'
|
||||||
luaassert(logfile ~= nil, 'no logfile')
|
assert(logfile ~= nil, 'no logfile')
|
||||||
nrlines = nrlines or 10
|
nrlines = nrlines or 10
|
||||||
|
|
||||||
M.retry(nil, 1000, function()
|
M.retry(nil, 1000, function()
|
||||||
@@ -161,7 +161,7 @@ function M.assert_log(pat, logfile, nrlines, inverse)
|
|||||||
local ismatch = not not text:match(pat)
|
local ismatch = not not text:match(pat)
|
||||||
if (ismatch and inverse) or not (ismatch or inverse) then
|
if (ismatch and inverse) or not (ismatch or inverse) then
|
||||||
local msg = string.format(
|
local msg = string.format(
|
||||||
'Pattern %s %sfound in log (last %d lines): %s:\n%s',
|
'Pattern %s %sfound in log (last %d lines): %q:\n%s',
|
||||||
vim.inspect(pat),
|
vim.inspect(pat),
|
||||||
(inverse and '' or 'not '),
|
(inverse and '' or 'not '),
|
||||||
nrlines,
|
nrlines,
|
||||||
@@ -187,7 +187,7 @@ end
|
|||||||
--- @param ... any
|
--- @param ... any
|
||||||
--- @return boolean, any
|
--- @return boolean, any
|
||||||
function M.pcall(fn, ...)
|
function M.pcall(fn, ...)
|
||||||
luaassert(type(fn) == 'function')
|
assert(type(fn) == 'function')
|
||||||
local status, rv = pcall(fn, ...)
|
local status, rv = pcall(fn, ...)
|
||||||
if status then
|
if status then
|
||||||
return status, rv
|
return status, rv
|
||||||
@@ -236,7 +236,7 @@ end
|
|||||||
--- @param fn function
|
--- @param fn function
|
||||||
--- @return string
|
--- @return string
|
||||||
function M.pcall_err_withfile(fn, ...)
|
function M.pcall_err_withfile(fn, ...)
|
||||||
luaassert(type(fn) == 'function')
|
assert(type(fn) == 'function')
|
||||||
local status, rv = M.pcall(fn, ...)
|
local status, rv = M.pcall(fn, ...)
|
||||||
if status == true then
|
if status == true then
|
||||||
error('expected failure, but got success')
|
error('expected failure, but got success')
|
||||||
@@ -785,7 +785,7 @@ end
|
|||||||
--- @return boolean
|
--- @return boolean
|
||||||
function M.is_ci(name)
|
function M.is_ci(name)
|
||||||
local any = (name == nil)
|
local any = (name == nil)
|
||||||
luaassert(any or name == 'github' or name == 'cirrus')
|
assert(any or name == 'github' or name == 'cirrus')
|
||||||
local gh = ((any or name == 'github') and nil ~= os.getenv('GITHUB_ACTIONS'))
|
local gh = ((any or name == 'github') and nil ~= os.getenv('GITHUB_ACTIONS'))
|
||||||
local cirrus = ((any or name == 'cirrus') and nil ~= os.getenv('CIRRUS_CI'))
|
local cirrus = ((any or name == 'cirrus') and nil ~= os.getenv('CIRRUS_CI'))
|
||||||
return gh or cirrus
|
return gh or cirrus
|
||||||
@@ -794,7 +794,8 @@ end
|
|||||||
-- Gets the (tail) contents of `logfile`.
|
-- Gets the (tail) contents of `logfile`.
|
||||||
-- Also moves the file to "${NVIM_LOG_FILE}.displayed" on CI environments.
|
-- Also moves the file to "${NVIM_LOG_FILE}.displayed" on CI environments.
|
||||||
function M.read_nvim_log(logfile, ci_rename)
|
function M.read_nvim_log(logfile, ci_rename)
|
||||||
logfile = logfile or os.getenv('NVIM_LOG_FILE') or '.nvimlog'
|
logfile = logfile or os.getenv('NVIM_LOG_FILE') or 'nvim.log'
|
||||||
|
assert(uv.fs_stat(logfile), ('logfile not found: %q'):format(logfile))
|
||||||
local is_ci = M.is_ci()
|
local is_ci = M.is_ci()
|
||||||
local keep = is_ci and 100 or 10
|
local keep = is_ci and 100 or 10
|
||||||
local lines = M.read_file_list(logfile, -keep) or {}
|
local lines = M.read_file_list(logfile, -keep) or {}
|
||||||
|
|||||||
Reference in New Issue
Block a user