aboutsummaryrefslogtreecommitdiff
path: root/test/functional/testnvim.lua
Commit message (Collapse)AuthorAge
* refactor(ruler)!: replace C implementation with 'rulerformat' expressionSébastien Hoffmann2026-08-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: The default 'ruler' is implemented in C instead of the 'statusline' DSL. Solution: Replace the C implementation with a default 'rulerformat' expression. This is a continuation of #1248 and #33036. Advantages: - configuration is more discoverable, the default being a useful example - users and plugins can augment the default - code reuse and less C code to maintain - ui2: due to the use of an item group with `minwid`, it can expand instead of truncating when the content gets too long, which is particularly useful for locales with long translations of Top/Bot/All Implementation details: As is the case for 'statusline', when trying to set 'rulerformat' to an empty string, the default expression is restored instead, mimicking how previously the default C implementation would have been activated. Just like before, `:set rulerformat=` and `:set rulerformat&` have the same effect, and the ruler is disabled with `:set noruler`. The default expression uses an item group with `%=`, unlike the fallback in the previous default statusline `%-14.(%l,%c%V%) %P`, because the total width and how it is configured is immediately clear without documentation, it is a more useful pattern in general that works when both sides have flexible width, and it also works for vim, which is useful for configuration sharing/reuse. A truncation marker `%<` is added at the end to mimic how at small screen widths, the scroll percentage would disappear first, so that the cursor position can remain fully visible. BREAKING CHANGES: - `&rulerformat` can no longer be set to an empty string - ui2: the default ruler is no longer of fixed width, but can expand - at very small screen widths (< 36 columns) - ui2: it will no longer try to shrink white-space before truncating - it truncates gradually from the right, whereas previously, the scroll percentage would disappear all at once - l10n can no longer add a space after the comma between line and column (this was only done for one language: Ukrainian)
* test(harness): migrate away from magic globalsJustin M. Keyes2026-07-21
| | | | | | | | | | | | | | | | | | | | | Problem: The magic globals `it`, `describe`, etc., are more trouble than they are worth. - Hooking into `after_each` requires `getfenv()` hacks. - They confuse luals/emmylua, because the top-level `.luarc.json` isn't merged with `test/.luarc.json` (apparently a luals limitation?) - They totally defeat discoverability because the user just has to "know" about the various magic symbols. So they harm DX, which means they serve no purpose at all. Solution: - Expose the test API from `testutil`, so tests can call `t.it()`, `t.describe()`, etc., in the conventional way. - Drop `getfenv()` hacks. - Drop the `setfenv()` injection in `load_chunk`. - Drop `test/_meta.lua`.
* test: improve Nvim EOF handling (for Windows CI) #40841Justin M. Keyes2026-07-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Mysterious Windows CI failure points to resource exhaustion, but we have no visibility/instrumentation: RUN T610 nvim_set_keymap, nvim_del_keymap can set mappings with special characters, lhs: <S-Left>, rhs: <S-Left>: 93.70 ms OK RUN T611 nvim_set_keymap, nvim_del_keymap can set mappings with special characters, lhs: <S-Left>, rhs: <F12><F2><Tab>: 49.48 ms FAIL …\testnvim.lua:144: EOF was received from Nvim. Likely the Nvim process crashed. stack traceback: D:/a/neovim/neovim/test/functional/testnvim.lua:144: in function 'nvim_set_keymap' …/api/keymap_spec.lua:769: in function <…/api/keymap_spec.lua:768> RUN T612 nvim_set_keymap, nvim_del_keymap can set mappings with special characters, lhs: <S-Left>, rhs: <Space><Tab>: 18.49 ms FAIL …\testnvim.lua:144: EOF was received from Nvim. Likely the Nvim process crashed. stack traceback: D:/a/neovim/neovim/test/functional/testnvim.lua:144: in function 'nvim_set_keymap' …/api/keymap_spec.lua:769: in function <.../build/Xtest_xdg_api/test/functional/api/keymap_spec.lua:768> Solution: Append the child exit-code and signal to the "EOF … crashed" message. Example: Nvim EOF (crash?) exit code: 42 (0x0000002A) On the next failing Windows run, the first crash line will classify the failure: - 0xC0000005 → access violation (nvim bug) - 0xC0000374 → heap corruption (nvim bug) - spawn/resource error or "clean" exit-code → system resource exhaustion
* test(pack): unreliable "vim.pack" tests on Windows #40717Justin M. Keyes2026-07-13
| | | | | | | | | | | FAILED …/plugin/pack_spec.lua:92: …/plugin/pack_spec.lua @ 70: vim.pack update() can use lockfile revision as a target …/plugin/pack_spec.lua:92: …/plugin/pack_spec.lua:70: process still exists stack traceback: D:/a/neovim/neovim/test/functional/testnvim/exec_lua.lua:124: in function 'system_sync' …/plugin/pack_spec.lua:92: in function 'git_cmd' …/plugin/pack_spec.lua:113: in function 'git_add_commit' …/plugin/pack_spec.lua:1209: in function <…/plugin/pack_spec.lua:1173> fix #40167
* test: "Failed to start server: address already in use" #40683Justin M. Keyes2026-07-11
| | | | | | | | | | | | | | Problem: unreliable test: FAILED …/tui_spec.lua @ 895: TUI mouse events work with right-click menu (escape sequences sent to child) D:/a/…/testnvim.lua:144: Vim:Failed to start server: address already in use stack traceback: D:/a/…/testnvim.lua:144: in function 'eval' D:/a/…/testnvim.lua:1015: in function 'new_pipename' …/tui_spec.lua:897: in function <…/tui_spec.lua:895> Solution: Workaround potential PID reuse.
* refactor(test): dedup benchmark utils #40478Justin M. Keyes2026-06-29
|
* test: run Lua harness with nvim -lLewis Russell2026-05-13
| | | | | | | | | | | | | | | | | | Problem: The Lua test harness still ran through standalone -ll mode, so tests depended on the low-level Lua path instead of the regular Nvim Lua environment. That also meant os.exit() coverage had to carry an ASAN workaround because Lua's raw process exit skipped Nvim teardown and let LeakSanitizer interfere with the observed exit code. Solution: Run the harness and related fixtures with nvim -l. Patch os.exit() in the main Lua state to exit through getout(), so scripts observe normal Nvim shutdown while standalone -ll remains available for generator-style scripts. As a consequence, the startup test can assert os.exit() without disabling leak detection. AI-assisted: Codex
* fix(build.zig): reunify parser install pathbfredl2026-04-23
| | | | | | Both for tests and for system wide install, $PREFIX/lib/nvim/parser is a valid path for tree-sitter parsers. This also brings the build.zig behavior in line with how we set up the paths in CMakeLists.txt
* refactor(test): drop deprecated exc_exec #39242Justin M. Keyes2026-04-20
|
* test: replace busted with local harnessLewis Russell2026-04-15
| | | | | | | | | | | | | | | | | | | Replace the busted-based Lua test runner with a repo-local harness. The new harness runs spec files directly under `nvim -ll`, ships its own reporter and lightweight `luassert` shim, and keeps the helper/preload flow used by the functional and unit test suites. Keep the file boundary model shallow and busted-like by restoring `_G`, `package.loaded`, `package.preload`, `arg`, and the process environment between files, without carrying extra reset APIs or custom assertion machinery. Update the build and test entrypoints to use the new runner, add black-box coverage for the harness itself, and drop the bundled busted/luacheck dependency path. AI-assisted: Codex
* test: n.rmdir() save-and-restore CWD #39048Justin M. Keyes2026-04-14
|
* test: include :cd in pcall() in rmdir() (#38278)zeertzjq2026-03-13
| | | | | | | | | | | If the Nvim session has exited, the nvim_command will fail too. ERROR test/functional/core/fileio_spec.lua @ 342: tmpdir failure modes test\functional\testnvim.lua:133: sending request after EOF from Nvim stack traceback: test\functional\testnvim.lua:133: in function 'command' test\functional\testnvim.lua:847: in function 'rmdir' test/functional/core\fileio_spec.lua:353: in function <test/functional/core\fileio_spec.lua:342>
* test(lsp): fix fake LSP server timeout not working (#37970)zeertzjq2026-02-19
| | | | | | | | | | Problem: Fake LSP server does not timeout or respond to SIGTERM as it does not run the event loop. Solution: Instead of io.read(), use stdioopen()'s on_stdin callback to accumulate input and use vim.wait() to wait for input. Also, in the test suite, don't stop a session when it's not running, as calling uv.stop() outside uv.run() will instead cause the next uv.run() to stop immediately, which cancels the next RPC request.
* test(ex_cmds/write_spec): don't create files under test/ (#37963)zeertzjq2026-02-19
|
* refactor(tests): server_spec #37912Justin M. Keyes2026-02-16
|
* feat(defaults): exclude temp dirs from 'shada' oldfiles #37631Pavel Pisetski2026-02-03
| | | | | | | | | | Problem: Temporary files from /tmp/ and /private/ paths clutter :oldfiles list. Additionally, the documented Windows default (rA:,rB:) was never applied due to a missing platform condition. Solution: Drop platform-specific shada differences and default to excluding /tmp/ and /private/ paths.
* fix(lua): close vim.defer_fn() timer if vim.schedule() failed (#37647)zeertzjq2026-02-01
| | | | | | | | Problem: Using vim.defer_fn() just before Nvim exit leaks luv handles. Solution: Make vim.schedule() return an error message if scheduling failed. Make vim.defer_fn() close timer if vim.schedule() failed.
* fix(shell): ceci n'est pas une pipebfredl2026-01-13
| | | | | | | | | | | | | | | | | | On linux /dev/stdin is defined as a symlink to /proc/self/fd/0 This in turn is defined as a "magic" symlink which is allowed to point to internal kernel objects which really does not have a file name. As a glaring inconsistency, fopen("/proc/self/fd/0", "r") works if fd was originally opened using pipe() but not using socketpair(). As it happens UV_CREATE_PIPE does not create pipes but creates socket pairs. These two unfortunate conditions means that using /dev/stdin and similar does not work in shell commands in nvim on linux. as a work around, override libuv's descicion and create an actual pipe pair. This change is not needed on BSD:s but done unconditionally for simplicity, except for on windows where it is not done for stdout because of windows fixes #35984
* test: skip noisy "terminal mode unavailable" logs #36794Justin M. Keyes2025-12-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Every CI log has a lot of noise at the end, which makes it harder to find relevant test failures: Running tests from test/functional/terminal/tui_spec.lua ... T5831 TUI bg color queries the terminal for background color: T5832 TUI bg color triggers OptionSet from automatic background processing: T5833 TUI bg color sends theme update notifications when background changes #31652: ... Running tests from test/functional/ui/output_spec.lua ... WRN 2025-12-02T03:36:47.304 ui/c/T5831.28003.0 tui_handle_term_mode:223: TUI: terminal mode 2026 unavailable, state 0 WRN 2025-12-02T03:36:47.359 ui/c/T5832.28006.0 tui_handle_term_mode:223: TUI: terminal mode 2048 unavailable, state 0 WRN 2025-12-02T03:36:47.414 ui/c/T5833.28009.0 tui_handle_term_mode:223: TUI: terminal mode 2048 unavailable, state 0 Solution: - Skip logging in test-mode. - This can be reverted later, when these logs are changed to "INFO" level, per this TODO comment: ``` // TODO(bfredl): This is really ILOG but we want it in all builds. // add to show_verbose_terminfo() without being too racy ???? WLOG("TUI: terminal mode %d unavailable, state %d", mode, state); ```
* docs: misc, build, lspJustin M. Keyes2025-11-22
|
* docs: getpos, getregion, lspJustin M. Keyes2025-11-15
|
* refactor(spell): cleanupJustin M. Keyes2025-10-26
| | | | | - prefer `stdpath(data)/site/spell` instead of looking for random dirs in 'runtimepath'. - drop unused functions `choose_directory`, `setup`, etc.
* test(tui_spec): avoid dangling Nvim processes on test failure (#35900)zeertzjq2025-09-24
| | | Also don't wait indefinitely for all Nvim processes to exit.
* test: don't block to wait for previous session's exit (#35885)zeertzjq2025-09-23
| | | This reduces the time taken by clear() by over 20% with ASAN.
* test: make error clearer for RPC request after crashzeertzjq2025-09-22
|
* feat(build): build.zig MVP: build and run functionaltests on linuxbfredl2025-05-02
| | | | | | | | | | | | | | | | | | | | | NEW BUILD SYSTEM! This is a MVP implementation which supports building the "nvim" binary, including cross-compilation for some targets. As an example, you can build a aarch64-macos binary from an x86-64-linux-gnu host, or vice versa Add CI target for build.zig currently for functionaltests on linux x86_64 only Follow up items: - praxis for version and dependency bumping - windows 💀 - full integration of libintl and gettext (or a desicion not to) - update help and API metadata files - installation into a $PREFIX - more tests and linters
* feat(options): default statusline expression #33036Shadman2025-04-21
| | | | | | | | | | Problem: Default 'statusline' is implemented in C and not representable as a statusline expression. This makes it hard for user configs/plugins to extend it. Solution: - Change the default 'statusline' slightly to a statusline expression. - Remove the C implementation.
* feat(defaults): shelltemp=false #33012Alexej Kowalew2025-04-12
| | | | Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* refactor(test): deprecate n.feed_command() #32915Justin M. Keyes2025-03-15
| | | | | | | | | | | Problem: `feed_command()` was added as a "bridge" for old test code. 99% of those cases should be using `n.command()`, which raises errors instead of silently continuing the test. Solution: Deprecate `feed_command()`. It should not be used in new tests. All usages of `feed_command()` should be converted to `command()` or `feed()`.
* test: do not dedent() in feed() (#32884)zeertzjq2025-03-14
| | | | Most callers of feed() do not expect feed() to dedent. Now use a literal space in tests where it looks better.
* test: simplify ASAN detectiondundargoc2025-03-02
|
* feat(lua): vim.text.indent()Justin M. Keyes2025-02-26
| | | | | | | | | | | | | Problem: Indenting text is a common task in plugins/scripts for presentation/formatting, yet vim has no way of doing it (especially "dedent", and especially non-buffer text). Solution: Introduce `vim.text.indent()`. It sets the *exact* indentation because that's a more difficult (and thus more useful) task than merely "increasing the current indent" (which is somewhat easy with a `gsub()` one-liner).
* refactor(tests): drop os_kill #32401Justin M. Keyes2025-02-11
| | | Also change job tests to use `nvim` instead of random programs like `ping`.
* feat(ui): UI :detach commandJustin M. Keyes2025-02-10
| | | | | | | | | | | Problem: Cannot detach the current UI. Solution: - Introduce `:detach`. - Introduce `Channel.detach`. Co-authored-by: bfredl <bjorn.linse@gmail.com>
* refactor(tests): merge n.spawn/n.spawn_argv into n.new_session #31859Justin M. Keyes2025-01-04
| | | | | | | | | | | | | | | | | Problem: - `n.spawn()` is misleading because it also connects RPC, it's not just "spawning" a process. - It's confusing that `n.spawn()` and `n.spawn_argv()` are separate. Solution: - Replace `n.spawn()`/`n.spawn_argv()` with a single function `n.new_session()`. This name aligns with the existing functions `n.set_session`/`n.get_session`. - Note: removes direct handling of `prepend_argv`, but I doubt that was important or intentional. If callers want to control use of `prepend_argv` then we should add a new flag to `test.session.Opts`. - Move `keep` to first parameter of `n.new_session()`. - Add a `merge` flag to `test.session.Opts` - Mark `_new_argv()` as private. Test should use clear/new_session/spawn_wait instead.
* test: use spawn_wait() instead of system() #31852Justin M. Keyes2025-01-04
| | | | | | | | | | | Problem: Tests that need to check `nvim` CLI behavior (no RPC session) create their own ad-hoc `system()` wrappers. Solution: - Use `n.spawn_wait` instead of `system()`. - Bonus: this also improves the tests by explicitly checking for `stdout` or `stderr`. And if a signal is raised, `ProcStream.status` will reflect it.
* test: include stderr in EOF failure messageJustin M. Keyes2025-01-03
|
* test: spawn_wait() starts a non-RPC Nvim processJustin M. Keyes2025-01-03
| | | | | | | | | | | Problem: Can't use `n.clear()` to test non-RPC `nvim` invocations. So tests end up creating ad-hoc wrappers around `system()` or `jobstart()`. Solution: - Introduce `n.spawn_wait()` - TODO (followup PR): Rename `n.spawn()` and `n.spawn_wait()`. It's misleading that `n.spawn()` returns a RPC session...
* feat(test): support and document lua test case debuggingMathias Fussenegger2024-12-24
| | | | | | | Similar to how there is a `GDB` environment variable to let the nvim test instances to be run under `gdbserver` this adds a `OSV_PORT` variable to start nvim test instances with `osv` in blocking mode to let a debug client attach to it for debugging of `exec_lua` code blocks.
* test: move exec_lua logic to separate moduleLewis Russell2024-11-21
| | | | | | | | | By making it a separate module, the embedded Nvim session can require this module directly instead of setup code sending over the module via RPC. Also make exec_lua wrap _G.print so messages can be seen in the test output immediately as the exec_lua returns.
* fix(test): better management of tmpfilesLewis Russell2024-11-06
| | | | | | | | | | | | | | | | | | | Problem: When tmpdir is local. The returned values from tmpname may already exist. This can cause problems for tests which pass `create=false` as they may require the file to not exist yet. Solution: When creating tmp names, always remove it to ensure it doesn't exist, and optionally open it if `create~=false` Additionally refactor the tmpname code and flattrn some functions into constants. Also while debugging this issue. It was discovered that `exec_lua()` doesn't report error messages properly. This has been fixed.
* feat(fs.lua): add vim.fs.rm()Lewis Russell2024-09-22
| | | | Analogous to the shell `rm` command.
* test: support upvalues in exec_luaLewis Russell2024-09-21
|
* feat(tui): builtin UI (TUI) sets client info #30397Justin M. Keyes2024-09-18
| | | | | | | | | | | | Problem: The default builtin UI client does not declare its client info. This reduces discoverability and makes it difficult for plugins to identify the UI. Solution: - Call nvim_set_client_info after attaching, as recommended by `:help dev-ui`. - Also set the "pid" field. - Also change `ui_active()` to return a count. Not directly relevant to this commit, but will be useful later.
* refactor(tests): rename terminal/testutil.lua => testterm.lua #30372Justin M. Keyes2024-09-15
| | | | | This module is generally used by any tests that need the full Nvim TUI instead of `screen.lua`. Thus it should live in `functional/` instead of in `functional/terminal/`.
* refactor(test): rename alter_slashes, invert its behaviorJustin M. Keyes2024-09-09
| | | | | | | - `alter_slashes` belongs in `testutil.lua`, not `testnvim.lua`. - `alter_slashes` is an unusual name. Rename it to `fix_slashes`. - invert its behavior, to emphasize that `/` slashes are the preferred, pervasive convention, not `\` slashes.
* fix(startup): server fails if $NVIM_APPNAME is relative dir #30310Justin M. Keyes2024-09-08
| | | | | | | | | | | | | | | | | | Problem: If $NVIM_APPNAME is a relative dir path, Nvim fails to start its primary/default server, and `v:servername` is empty. Root cause is d34c64e342dfba9248d1055e702d02620a1b31a8, but this wasn't noticed until 96128a5076b7 started reporting the error more loudly. Solution: - `server_address_new`: replace slashes "/" in the appname before using it as a servername. - `vim_mktempdir`: always prefer the system-wide top-level "nvim.user/" directory. That isn't intended to be specific to NVIM_APPNAME; rather, each *subdirectory* ("nvim.user/xxx") is owned by each Nvim instance. Nvim "apps" can be identified by the server socket(s) stored in those per-Nvim subdirs. fix #30256
* fix(scrollbind): properly take filler/virtual lines into accountLewis Russell2024-07-31
| | | | | | | | | | | | | | | | | | Problem: `'scrollbind'` does not work properly if the window being scrolled automatically contains any filler/virtual lines (except for diff filler lines). This is because when the scrollbind check is done, the logic only considers changes to topline which are represented as line numbers. Solution: Write the logic for determine the scroll amount to take into account filler/virtual lines. Fixes #29751
* Merge pull request #29103 from gpanders/test-no-tgcGregory Anders2024-06-12
|\ | | | | test: do not set termguicolors in test runner
| * test: do not set termguicolors in test runnerGregory Anders2024-05-31
| | | | | | | | | | It's not clear why this is needed and it has adverse side effects on other tests.