summaryrefslogtreecommitdiffstatshomepage
path: root/test/unit
AgeCommit message (Collapse)AuthorFiles
2026-04-15test: replace busted with local harnessLewis Russell7
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
2026-04-15test(vterm): retain ffi callback structsLewis Russell1
AI-assisted: Codex
2026-03-29vim-patch:9.2.0253: various issues with wrong b_nwindows after closing buffersSean Dewar1
Problem: close_buffer() callers incorrectly handle b_nwindows, especially after nasty autocmds, allowing it to go out-of-sync. May lead to buffers that can't be unloaded, or buffers that are prematurely freed whilst displayed. Solution: Modify close_buffer() and review its callers; let them decrement b_nwindows if it didn't unload the buffer. Remove some now unneeded workarounds like 8.2.2354, 9.1.0143, 9.1.0764, which didn't always work (Sean Dewar) (endless yapping omitted) related: vim/vim#19728 https://github.com/vim/vim/commit/bf21df1c7bc772e3a29961c961d0821584d50ee0 b_nwindows = 0 change for free_all_mem() was already ported. Originally Nvim returned true when b_nwindows was decremented before the end was reached (to better indicate the decrement). That's not needed anymore, so just return true only at the end, like Vim. (retval isn't used anywhere now anyways) Set textlock for dict watchers at the end of close_buffer() to prevent them from switching windows, as that can leave a window with a NULL buffer. (possible before this PR, but the new assert catches it; added a test) Despite textlock, things still aren't ideal, as watchers may observe the buffer as unloaded and hidden (b_nwindows was decremented), yet still in a window... Likewise, for Nvim, wipe_qf_buffer()'s comment may not be entirely accurate; autocmds are blocked, but on_detach callbacks (textlocked) and dict watchers may still run. Might be problematic, but those aren't new issues. Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
2026-03-21fix(mpack): boundary values for negative integer encoding #37255benarcher26911
Problem: libmpack encodes boundary values -129 and -32769 with wrong integer sizes: - -129 as int8 instead of int16 - -32769 as int16 instead of int32 because the boundary checks compare against the wrong values (e.g., lo < 0xffffff7f instead of lo < 0xffffff80). This caused data corruption: -129 would decode as 127. Solution: Fix off-by-one errors in the two's complement boundary constants: 0xffffff80 (-128, min int8) and 0xffff8000 (-32768, min int16). Fixes #37202 Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-17feat(terminal): synchronized output (mode 2026) #38284mgleonard4252
Problem: Applications running inside :terminal that use DEC private mode 2026 (synchronized output) to batch screen updates get garbled rendering. Neovim's embedded libvterm does not handle mode 2026, so the synchronization sequences are ignored and intermediate screen states leak through as visual corruption. Solution: Add mode 2026 support to libvterm's state machine and wire it through to terminal.c. When an application enables mode 2026, invalidation of the terminal buffer is deferred until the application disables it, causing all accumulated screen updates to flush as a single atomic refresh. * fix(terminal): harden sync output redraw gating Problem: The initial mode 2026 implementation gated invalidate_terminal() but missed three other redraw paths: term_sb_push/term_sb_pop bypassed the gate by directly adding to invalidated_terminals, refresh_timer_cb could fire mid-sync flushing partial state, and the 10ms timer delay after sync-end left a window for stale repaints. Solution: - Gate term_sb_push/term_sb_pop during synchronized output - Skip syncing terminals in refresh_timer_cb - On sync end, schedule a zero-delay full-screen refresh via sync_flush_pending flag in terminal_receive() - Add news.txt entry for mode 2026 support Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * test(terminal): add vterm unit tests for mode 2026 Add unit-level tests for synchronized output (mode 2026) to vterm_spec.lua, covering settermprop callbacks and DECRQM query/response. Suggested-by: justinmk Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(terminal): address review feedback for mode 2026 - Use multiqueue_put(main_loop.events) instead of restarting the global refresh timer on sync end, to avoid affecting other invalidated terminals. - Add screen:expect_unchanged() to verify screen doesn't update during sync mode. - Merge buffer-lines test into existing test. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-28vim-patch:9.2.0078: [security]: stack-buffer-overflow in build_stl_str_hl() ↵zeertzjq1
(#38102) Problem: A stack-buffer-overflow occurs when rendering a statusline with a multi-byte fill character on a very wide terminal. The size check in build_stl_str_hl() uses the cell width rather than the byte length, allowing the subsequent fill loop to write beyond the 4096-byte MAXPATHL buffer (ehdgks0627, un3xploitable). Solution: Update the size check to account for the byte length of the fill character (using MB_CHAR2LEN). Github Advisory: https://github.com/vim/vim/security/advisories/GHSA-gmqx-prf2-8mwf https://github.com/vim/vim/commit/4e5b9e31cb7484ad156fba995fdce3c9b075b5fd Co-authored-by: Christian Brabandt <cb@256bit.org>
2026-02-27feat(terminal): support SGR dim, overline attributes #37997Riccardo Mazzarini2
Problem: libvterm doesn't support parsing the dim and overline attributes, so when a program running in the embedded terminal emits one of these escape codes, we ignore it and don't surface it to the outer terminal. Solution: tweak libvterm to add support for both attributes.
2026-02-26fix(marktree): fix edge case bug regarding changing intersectionsbfredl1
fix #37867 This bug happens when only one end is moved between different nodes, but the other end is also moved but within the same node. When this happens we need the correct previous position even for the internal move. This code shall be refactored to make the intent clearer, (and avoid some unnecessary processing) but this is a fix for the observable bug. Thanks to KevinGoodsell for providing a deterministic reproduce using fuzzing techniques.
2026-02-23fix(logging): don't overwrite NameBuff (#38004)zeertzjq1
2026-02-19vim-patch:9.2.0020: Wrong shortened buffer after :cd with duplicate slashes ↵zeertzjq1
(#37955) Problem: Wrong shortened buffer name after :cd with duplicate slashes. Solution: Skip over multiple consecutive path separators (zeertzjq). related: neovim/neovim#37080 closes: vim/vim#19444 https://github.com/vim/vim/commit/f245e17ac70df43fd7fe650c7227bb16a4615283 N/A patches: vim-patch:9.0.1859: heap-use-after-free in bt_normal() vim-patch:9.2.0022: bt_quickfix() is slow
2026-02-16fix(coverity/637363): out-of-bounds write #37878Jibril1
Problem: stack->offset value is used as an array index. Solution: Instead of comparing the stack->offset value to the size in bytes of the array, compare the actual length of the array.
2026-02-16vim-patch:8.2.3841: Vim9: outdated TODO items, disabled tests that work (#37900)zeertzjq1
Problem: Vim9: outdated TODO items, disabled tests that work. Solution: Remove TODO items, run tests that work now. Check that a dict item isn't locked. https://github.com/vim/vim/commit/71b768509250b12696e8cc90e5902029f1b5433d Co-authored-by: Bram Moolenaar <Bram@vim.org>
2026-02-06fix(vterm): handle split UTF-8 after ASCII properly (#37721)zeertzjq1
Problem: libvterm doesn't handle split UTF-8 sequence after ASCII. Solution: Only use one UTF-8 encoding state per vterm state.
2026-02-05fix(terminal): handle split composing chars at right edge (#37694)zeertzjq1
Problem: Recombining composing chars in terminal doesn't work at right edge. Solution: Check for the case where printing the previous char didn't advance the cursor. Reset at_phantom when returning to combine_pos.
2026-01-21test: fix some type warnings (#37483)zeertzjq2
2026-01-17fix(api): parse_expression crash with unopened ] and nodeSean Dewar1
Problem: nvim_parse_expression null pointer dereference with unmatched ] followed by a node. Solution: if ast_stack was empty, set new_top_node_p to top of the stack after pushing the list literal node; similar to what's done for curlies. This bug was originally found by a Matrix user, but I couldn't remember how to trigger it... Ran into the other crash while finding a repro. :P
2026-01-15fix(typval): allocated dynamic size must be at least the static sizebfredl1
fixes #37160
2026-01-12docs: misc (#37281)zeertzjq1
Close #37289 Close #37348 Co-authored-by: Marc Jakobi <marc@jakobi.dev> Co-authored-by: Anton Kesy <anton@kesy.de>
2025-11-18build(test): unknown 'ipc_info_object_type_t' type on macOS #36523Koichi Shiraishi1
Problem: On macOS Tahoe, `make unittest` started failing with the following error. ```` test/unit/testutil.lua:784: test/unit/testutil.lua:768: (string) ' test/unit/testutil.lua:295: declaration specifier expected near 'ipc_info_object_type_t' at line 2297' exit code: 256 stack traceback: test/unit/testutil.lua:784: in function 'itp_parent' test/unit/testutil.lua:822: in function <test/unit/testutil.lua:812> ```` Solution: Update filter_complex_blocks.
2025-11-15refactor(path)!: support RFC3986 in path_with_url() #36564Chip Senkbeil1
Problem: Nvim does not recognize URI scheme with numeric characters. While rare, there are URIs that contain numbers (e.g. [ed2k://](https://en.wikipedia.org/wiki/Ed2k_URI_scheme)) and characters like `+` (e.g. `svn+ssh`). I use it in [distant.nvim](https://github.com/chipsenkbeil/distant.nvim) to support multiple, distinct connections using `distant+1234://` as the scheme. Otherwise, if you open a file with the same name & path on two different machines from the same Nvim instance, their buffer names will conflict when just using `distant://`. Solution: Adds full support for detecting URI scheme per [RFC3986](https://www.rfc-editor.org/rfc/rfc3986#section-3.1)
2025-11-12fix(tests): use correct signature for unpacker_teardown()bfredl1
2025-10-29refactor(termkey): make termkey use internal terminfo properlybfredl1
problem: termkey/driver-ti.c had its internal dependency upon unibilium which would completely skip builtin terminfo defs. solution: add termkey info to TerminfoEntry struct NOTE: this disables a lot of named function keys which are present as terminfo "keys" both are mostly unset in terminfo entries for modern terminals, and also not recognized by nvim as mappable keys anyway, except a few ones like `<undo>` which this still will keep. We probably don't want to encode up to F63 keys forever. While only 12 physical keys are available on modern keybords, instead Chords using F-keys are usually encoded as high key numbers, like <C-S-F3> becoming <F39> . But reconsideirg that has implications for configuration that is best done as a separate (breaking) change.
2025-09-26test: make preload of functional/testnvim.lua explicit (#35919)zeertzjq1
Before functional/testnvim.lua was moved from functional/testutil.lua in 052498ed42780a76daea589d063cd8947a894673, it was explicitly preloaded, but now it is preloaded implicitly via functional/ui/screen.lua. Also fix warnings about unused variables in other preload.lua files.
2025-09-26test(unit): disable JIT when using mocks (#35913)zeertzjq2
This fixes the flaky eval/typval_spec.lua tests.
2025-09-06fix(tests): ignore vector math typesJames McCoy1
As noted in #34908, the arm unittests fail due to unrecognized types: ERROR test/unit/testutil.lua @ 802: Expressions parser works with &opt test/unit/testutil.lua:774: test/unit/testutil.lua:758: (string) ' test/unit/testutil.lua:288: declaration specifier expected near '__SVFloat32_t'' exit code: 256 After testing on Debian's arm64 porterbox, the unittests cleanly pass when ignoring various types defined in /usr/include/aarch64-linux-gnu/bits/math-vector.h
2025-08-27refactor: rename ga_concat_strings_sep() to ga_concat_strings() (#35498)zeertzjq1
This adds a missing change from Vim patch 7.4.279. N/A patch: vim-patch:9.1.1691: over-allocation in ga_concat_strings()
2025-08-14refactor(build): remove INCLUDE_GENERATED_DECLARATIONS guardsbfredl1
These are not needed after #35129 but making uncrustify still play nice with them was a bit tricky. Unfortunately `uncrustify --update-config-with-doc` breaks strings with backslashes. This issue has been reported upstream, and in the meanwhile auto-update on every single run has been disabled.
2025-07-26fix(unittests): use -1ULL to mean UNSIGNED MATH.MAXbfredl2
2025-07-20vim-patch:8.1.1891: functions used in one file are globalJan Edmund Lazo1
Problem: Functions used in one file are global. Solution: Add "static". (Yegappan Lakshmanan, closes vim/vim#4840) https://github.com/vim/vim/commit/5843f5f37b0632e2d706abc9014bfd7d98f7b02e Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-07-15refactor(vterm): update vterm DA1 responseGregory Anders1
Update vterm's DA1 response to the more modern version that indicates level 1 support for VT100 emulation (61) as well as ANSI color support (22).
2025-07-09feat(tui): use DA1 response to determine OSC 52 supportGregory Anders1
Many terminals now include support for OSC 52 in their Primary Device Attributes (DA1) response. This is preferable to using XTGETTCAP because DA1 is _much_ more broadly supported.
2025-05-22fix(tests): use correct include path for unittestbfredl2
Copy whatever was made to work for generated headers: (1) we need to consider all cmake targets not just main_lib (2) we need to add the sysroot for macOS
2025-05-22fix(tests): use uv.spawn instead of io.popen for unittest helpersbfredl3
The old implementation of repeated_read_cmd would attempt to run the command multiple times to handle racyness of async output. Code like this should not be written. Instead, use the libuv event loop to read until the process has exited and the pipe has been closed. This causes some previous discarded errors to be propagated. Fix these as well.
2025-04-16fix(env.c): drop envmap, free os_getenv() result #32683Judit Novak1
Problem: vim.uv.os_setenv gets "stuck" per-key. #32550 Caused by the internal `envmap` cache. #7920 :echo $FOO <-- prints nothing :lua vim.uv.os_setenv("FOO", "bar") :echo $FOO <-- prints bar (as expected) :lua vim.uv.os_setenv("FOO", "fizz") :echo $FOO <-- prints bar, still (not expected. Should be "fizz") :lua vim.uv.os_unsetenv("FOO") :echo $FOO <-- prints bar, still (not expected. Should be nothing) :lua vim.uv.os_setenv("FOO", "buzz") :echo $FOO <-- prints bar, still (not expected. Should be "buzz") Solution: - Remove the `envmap` cache. - Callers to `os_getenv` must free the result. - Update all call-sites. - Introduce `os_getenv_noalloc`. - Extend `os_env_exists()` the `nonempty` parameter.
2025-03-09Merge #32687 "g<" for ext_messagesJustin M. Keyes2
2025-03-08refactor(multiqueue): rename multiqueue_new_parent #32767Justin M. Keyes1
2025-03-03refactor(messages): simplify message historyLuuk van Baal2
2025-03-02test: simplify ASAN detectiondundargoc1
2025-02-22test(unit/strings_spec): show ctx when vim_snprintf content check fails #32570James McCoy1
Same idea as a7be4b7bf857, but that only showed the context if the length of the string differed. Since these tests check both string length and string content, the ctx should be provided for both. ERROR test/unit/testutil.lua @ 797: vim_snprintf() positional arguments test/unit/testutil.lua:769: test/unit/testutil.lua:753: (string) ' test/unit/strings_spec.lua:159: snprintf(buf, 4, "%1$0.*2$b", 12ULL, cdata<int>: 0xf78c8ed8) = 001100 Expected objects to be the same. Passed in: (string) '000' Expected: (string) '001''
2025-02-22fix(tests): filter out lines with __typeof__ keyword (#32524)Sören Tempel1
Problem: On 32-bit architectures, musl libc makes heavy use of __typeof__ as part of its __REDIR macro for optional backwards compatibility with 32-bit time_t values. Unfortunately, the __typeof__ keyword is not supported by the LuaJIT C parser. Solution: Filter out the keyword in filter_complex_blocks.
2025-02-18fix(tests): remove the __extension__ keyword in filter_complex_blocks (#32483)Sören Tempel1
Problem: This keyword is used by GCC and Clang to prevent -Wpedantic (and other options) from emitting warnings for many GNU C extensions. This is used heavily in Alpine Linux through musl libc and foritfy-headers. Without filtering the __extension__ keyword some type definitions are duplicated. For example, timeval is defined once as struct timeval { time_t tv_sec; suseconds_t tv_usec; }; and once as: __extension__ struct timeval { time_t tv_sec; suseconds_t tv_usec; }; Without this patch, the LuaJIT C parser doesn't recognize that these definitions are equivalent, causing unit test to fail on Alpine Linux. Solution: Filter out the keyword in filter_complex_blocks.
2025-01-29test(unit/strings_spec): use correct type for binary valuesJames McCoy1
When 9.0.1856 was ported, the numbers being formatted as binary were cast to "unsigned int" rather than uvarnumber_T, as is done upstream.
2025-01-28test(unit/strings_spec): provide context for vim_snprintf testsJames McCoy1
Since these assertions all use a common function to perform the test assertions, it's difficult to figure out which test failed: ERROR test/unit/testutil.lua @ 785: vim_snprintf() positional arguments test/unit/testutil.lua:757: test/unit/testutil.lua:741: (string) ' test/unit/strings_spec.lua:143: Expected objects to be the same. Passed in: (number) 6400 Expected: (number) 6' exit code: 256 Adding context to the assertion makes it clearer what the problem is: ERROR test/unit/testutil.lua @ 785: vim_snprintf() positional arguments test/unit/testutil.lua:757: test/unit/testutil.lua:741: (string) ' test/unit/strings_spec.lua:149: snprintf(buf, 0, "%1$0.*2$b", cdata<unsigned int>: 0xf78d0f38, cdata<int>: 0xf78dc4e0) = 001100 Expected objects to be the same. Passed in: (number) 6400 Expected: (number) 6' exit code: 256
2025-01-21feat(terminal): forward X1 and X2 mouse eventszeertzjq1
Ref: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Other-buttons
2025-01-16test: use esc sequences in vterm unit testsGregory Anders1
2025-01-16feat(terminal): add support for kitty keyboard protocolGregory Anders1
This commit adds basic support for the kitty keyboard protocol to Neovim's builtin terminal. For now only the first mode ("Disambiguate escape codes") is supported.
2025-01-14feat(terminal): support theme update notifications (DEC mode 2031) (#31999)Gregory Anders1
2025-01-13fix(options): better handling of empty valuesLewis Russell1
Problem: Whether an option is allowed to be empty isn't well defined and isn't properly checked. Solution: - For non-list string options, explicitly check the option value if it is empty. - Annotate non-list string options that can accept an empty value. - Adjust command completion to ignore the empty value. - Render values in Lua meta files
2025-01-13refactor: delete duplicate utf8-functionalitydundargoc1
Also remove British National Replacement Character Set. We keep the DEC Special Graphics and ASCII despite it not being unicode as some old software such as calcurse still rely on this functionality. References: - https://github.com/neovim/neovim/pull/31934#discussion_r1911046426 - https://en.wikipedia.org/wiki/DEC_Special_Graphics - https://vt100.net/docs/vt220-rm/chapter2.html#S2.4.3
2025-01-11docs: miscdundargoc2
Co-authored-by: Axel <axelhjq@gmail.com> Co-authored-by: Colin Kennedy <colinvfx@gmail.com> Co-authored-by: Daiki Noda <sys9kdr@users.noreply.github.com> Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com> Co-authored-by: Jean-Jacq du Plessis <1030058+jj-du-plessis@users.noreply.github.com> Co-authored-by: Juan Giordana <juangiordana@gmail.com> Co-authored-by: Lincoln Wallace <locnnil0@gmail.com> Co-authored-by: Matti Hellström <hellstrom@scm.com> Co-authored-by: Steven Locorotondo <steven.locorotondo@justeattakeaway.com> Co-authored-by: Yochem van Rosmalen <git@yochem.nl> Co-authored-by: glepnir <glephunter@gmail.com> Co-authored-by: ifish <fishioon@live.com>