mirror of
https://github.com/neovim/neovim.git
synced 2026-03-30 20:32:08 +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
|
||||
INSTALL_PREFIX: ${{ github.workspace }}/nvim-install
|
||||
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
|
||||
VALGRIND_LOG: ${{ github.workspace }}/build/log/valgrind-%p.log
|
||||
# TEST_FILE: test/functional/core/startup_spec.lua
|
||||
@@ -176,6 +176,7 @@ jobs:
|
||||
TEST_TIMEOUT: 600
|
||||
run: |
|
||||
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
|
||||
exit_code="$?"
|
||||
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/*.ck
|
||||
|
||||
# Generated by tests with $NVIM_LOG_FILE set.
|
||||
/.nvimlog
|
||||
|
||||
# Generated by scripts/vim-patch.sh
|
||||
/.vim-src
|
||||
*.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})
|
||||
|
||||
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()
|
||||
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 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
|
||||
skipped.
|
||||
@@ -80,6 +80,10 @@ To run only _unit_ tests: >
|
||||
To run only _functional_ tests: >
|
||||
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
|
||||
|
||||
|
||||
@@ -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
|
||||
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
|
||||
|
||||
LOG FILE (DEFAULT) ~
|
||||
`$NVIM_LOG_FILE` Nvim: stdpath("log")/log
|
||||
Unix: ~/.local/state/nvim ~/.local/state/nvim/log
|
||||
Windows: ~/AppData/Local/nvim-data ~/AppData/Local/nvim-data/log
|
||||
`$NVIM_LOG_FILE` Nvim: stdpath("log")/nvim.log
|
||||
Unix: ~/.local/state/nvim ~/.local/state/nvim/nvim.log
|
||||
Windows: ~/AppData/Local/nvim-data ~/AppData/Local/nvim-data/nvim.log
|
||||
|
||||
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
|
||||
debugging, plugins and RPC clients. >
|
||||
:echo $NVIM_LOG_FILE
|
||||
By default, the file is located at stdpath("log")/log ($XDG_STATE_HOME/nvim/log)
|
||||
unless that path is inaccessible or if $NVIM_LOG_FILE was set before |startup|.
|
||||
Default location is stdpath("log")/log ($XDG_STATE_HOME/nvim/nvim.log) unless
|
||||
that path is inaccessible or $NVIM_LOG_FILE was set before |startup|.
|
||||
|
||||
|
||||
vim:noet:tw=78:ts=8:ft=help:norl:
|
||||
|
||||
@@ -351,7 +351,7 @@ Defaults to
|
||||
.Ic ":help $NVIM_APPNAME"
|
||||
.It Ev NVIM_LOG_FILE
|
||||
Low-level log file, usually found at
|
||||
.Pa ~/.local/state/nvim/log .
|
||||
.Pa ~/.local/state/nvim/nvim.log .
|
||||
.Ic ":help $NVIM_LOG_FILE"
|
||||
.It Ev 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.
|
||||
///
|
||||
/// 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
|
||||
/// and $HOME environment variables are undefined.
|
||||
static void log_path_init(void)
|
||||
@@ -78,12 +78,12 @@ static void log_path_init(void)
|
||||
}
|
||||
XFREE_CLEAR(loghome);
|
||||
// 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);
|
||||
xfree(defaultpath);
|
||||
// Fall back to .nvimlog
|
||||
// Fall back to $CWD/nvim.log
|
||||
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
|
||||
if (len >= size || !log_try_create(log_file_path)) {
|
||||
|
||||
@@ -252,7 +252,7 @@ describe('startup defaults', function()
|
||||
eq('Xtest-logpath', eval('$NVIM_LOG_FILE'))
|
||||
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))
|
||||
clear({
|
||||
env = {
|
||||
@@ -260,10 +260,10 @@ describe('startup defaults', function()
|
||||
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)
|
||||
|
||||
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))
|
||||
clear({
|
||||
env = {
|
||||
@@ -271,7 +271,7 @@ describe('startup defaults', function()
|
||||
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.
|
||||
expect_exit(command, 'qall!')
|
||||
end)
|
||||
|
||||
@@ -73,8 +73,8 @@ end
|
||||
--- @param fn function
|
||||
--- @return any
|
||||
function M.retry(max, max_ms, fn)
|
||||
luaassert(max == nil or max > 0)
|
||||
luaassert(max_ms == nil or max_ms > 0)
|
||||
assert(max == nil or max > 0)
|
||||
assert(max_ms == nil or max_ms > 0)
|
||||
local tries = 1
|
||||
local timeout = (max_ms and max_ms or 10000)
|
||||
local start_time = uv.now()
|
||||
@@ -112,12 +112,12 @@ end
|
||||
--- @param expected (any) description of expected result
|
||||
--- @param actual (any) description of actual result
|
||||
function M.ok(cond, expected, actual)
|
||||
luaassert(
|
||||
assert(
|
||||
(not expected and not actual) or (expected and actual),
|
||||
'if "expected" is given, "actual" is also required'
|
||||
)
|
||||
local msg = expected and ('expected %s, got: %s'):format(expected, tostring(actual)) or nil
|
||||
return luaassert(cond, msg)
|
||||
return assert(cond, msg)
|
||||
end
|
||||
|
||||
local function epicfail(state, arguments, _)
|
||||
@@ -151,8 +151,8 @@ end
|
||||
---@param nrlines? (number) Search up to this many log lines (default 10)
|
||||
---@param inverse? (boolean) Assert that the pattern does NOT match.
|
||||
function M.assert_log(pat, logfile, nrlines, inverse)
|
||||
logfile = logfile or os.getenv('NVIM_LOG_FILE') or '.nvimlog'
|
||||
luaassert(logfile ~= nil, 'no logfile')
|
||||
logfile = logfile or os.getenv('NVIM_LOG_FILE') or 'nvim.log'
|
||||
assert(logfile ~= nil, 'no logfile')
|
||||
nrlines = nrlines or 10
|
||||
|
||||
M.retry(nil, 1000, function()
|
||||
@@ -161,7 +161,7 @@ function M.assert_log(pat, logfile, nrlines, inverse)
|
||||
local ismatch = not not text:match(pat)
|
||||
if (ismatch and inverse) or not (ismatch or inverse) then
|
||||
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),
|
||||
(inverse and '' or 'not '),
|
||||
nrlines,
|
||||
@@ -187,7 +187,7 @@ end
|
||||
--- @param ... any
|
||||
--- @return boolean, any
|
||||
function M.pcall(fn, ...)
|
||||
luaassert(type(fn) == 'function')
|
||||
assert(type(fn) == 'function')
|
||||
local status, rv = pcall(fn, ...)
|
||||
if status then
|
||||
return status, rv
|
||||
@@ -236,7 +236,7 @@ end
|
||||
--- @param fn function
|
||||
--- @return string
|
||||
function M.pcall_err_withfile(fn, ...)
|
||||
luaassert(type(fn) == 'function')
|
||||
assert(type(fn) == 'function')
|
||||
local status, rv = M.pcall(fn, ...)
|
||||
if status == true then
|
||||
error('expected failure, but got success')
|
||||
@@ -785,7 +785,7 @@ end
|
||||
--- @return boolean
|
||||
function M.is_ci(name)
|
||||
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 cirrus = ((any or name == 'cirrus') and nil ~= os.getenv('CIRRUS_CI'))
|
||||
return gh or cirrus
|
||||
@@ -794,7 +794,8 @@ end
|
||||
-- Gets the (tail) contents of `logfile`.
|
||||
-- Also moves the file to "${NVIM_LOG_FILE}.displayed" on CI environments.
|
||||
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 keep = is_ci and 100 or 10
|
||||
local lines = M.read_file_list(logfile, -keep) or {}
|
||||
|
||||
Reference in New Issue
Block a user