aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ex_cmds/write_spec.lua
Commit message (Collapse)AuthorAge
* fix(write): crash when pre-write autocmd changes cwd #41840Shantanu Raj2026-09-11
| | | | | | | | | | Problem: A :cd, or a window-context restore (nvim_win_call(), win_execute()), in a pre-write autocmd clears the short name of a buffer outside the current directory. buf_write then copies a NULL filename and crashes. Solution: Rebind short-name aliases to b_fname, which retains the effective filename. Add a regression for a BufWritePre autocmd changing cwd away from the file.
* fix(write): :write can target a garbage filename #41432Justin M. Keyes2026-08-22
| | | | | | | | | | | | | | | | | | | | | | | | | Problem: `buf_write()` captures the buffer's `fname`/`sfname`/`ffname`, then emits its progress-message before opening the file. This may run user code synchronously: the `Progress` autocmd, and the `msg_show` handler of an in-process UI (ui2). Either can change the CWD, and `shorten_fnames()` then frees/reallocs every buffer's short name. The rest of `buf_write()` reads the freed name... "foldtext()" [New] 41L, 997B written E212: Can't open file for writing: illegal byte sequence ASAN, with ui2 enabled and a `BufEnter` handler that runs `:lcd`: READ path_skip_sep <- path_tail <- match_file_list <- buf_write FREE shorten_buf_fname <- shorten_fnames <- update_cwd <- set_curbuf <- win_set_buf <- nvim_open_win <- ui2 msg_show handler <- ui_call_msg_show <- msg_ext_ui_flush <- buf_write Solution: Copy the names after the `*Pre` autocmds. Note: `readfile()` has the same shape, but its messages pass no progress-id, so they skip `msg_progress()`. Safe, for now...
* 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`.
* fix(write): show E17 on all platforms #40595Willaaaaaaa2026-07-19
| | | | | | | | | Problems: On Windows, `:w somedir` (where somedir is an existing directory in pwd) shows the misleading `E13: File exists (add ! to override)` instead of `E17: "somedir" is a directory`. Solution: drop unnecessary `#ifdef` guard.
* test: mark non-actionable tests as N/A #40207Justin M. Keyes2026-06-12
| | | | | | | | | | Problem: Listing individual "skipped" notices for each non-actionable or NVIM_TEST_INTEG test is noisy and makes the "skipped" list overwhelming and less meaningful. Solution: - Mark non-actionable tests with "N/A". - Report NVIM_TEST_INTEG tests as a separate 1-line summary.
* ci: drop cirrus #39321Justin M. Keyes2026-04-22
| | | | | | | | Problem: cirrus will shutdown soon, and we are running out of minutes anyway, which causes ci failures. Solution: Drop cirrus config.
* fix(cmd): ++p, ++edit should match "word" boundary #39146glepnir2026-04-22
| | | | | | | | Problem: `:write ++patate foo` doesn't error out, instead it turns on mkdir_p and uses "atate foo" as the filename. Same with ++edit. The parser just does strncmp without checking what comes after. Solution: require the next char after the option name to not be a letter
* refactor(test): drop deprecated exc_exec #39242Justin M. Keyes2026-04-20
|
* test(ex_cmds/write_spec): don't create files under test/ (#37963)zeertzjq2026-02-19
|
* fix(bufwrite.c): handle invalid byte sequences #37363Kevin Goodsell2026-02-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: bw_rest was used as an extra buffer to save incomplete byte sequences between calls to buf_write_bytes. Besides being unnecessarily complicated, this introduced a number of issues: 1) The bytes stored in bw_rest could still be there at the end of writing the file, never having been written, thus losing some of the file content on write. 2) bw_rest was not cleared out after the "checking_conversion" phase, leaving them to affect the written file content during the writing phase, corrupting the file. 3) bw_rest could contain extra bytes that need to be written to the output buffer during a buf_write_convert call, potentially before any bytes are consumed. But some conversions are in-place, without a separate output buffer. Writing bytes from bw_rest to the "output" buffer actually overwrote bytes from the input buffer before they were read, corrupting the data to be written. 4) The extra bytes in bw_rest that need to be written to the conversion output buffer were not originally accounted for in the size calculation for the output buffer, causing a buffer overflow (previously fixed in Vim patch 9.1.2028). Solution: Rather than maintaining a separate buffer, the unconverted bytes at the end of the buffer can just be shifted to the beginning of the buffer, and the buffer size updated. This requires a bit of refactoring, and buf_write_convert and buf_write_convert_with_iconv need to report the number of bytes they consumed so that buf_write_bytes can handle the remaining bytes. Following conversion, bw_buf can be checked for any remaining bytes. Leftover bytes in this case result in a conversion error, which is better than silently dropping them. A short section of dead code was removed from buf_write_convert, for converting a non-UTF-8 buffer to UTF-8. Neovim buffers are always UTF-8. A few additional tests for iconv conversions have been added. Vim's iconv tests are disabled in Neovim because they use unsupported values for 'encoding'.
* feat: ":wall ++p" creates parent dirs for each buf #36121Rob Pilling2025-10-11
| | | | `:wall ++p` will create parent directories if they do not exist, for each modified buffer
* fix(cmd): :update writes new file buffers only for real files #35939glepnir2025-09-27
| | | | | | | Problem: :update should write new file buffers, but previous fix affected special buffer types (acwrite, nofile, etc.). Solution: Add bt_nofilename() check to only write new files for buffers representing real filesystem paths.
* fix(cmd): :update does not write new, unmodified buffer #35929glepnir2025-09-27
| | | | | | | Problem: update command does not write new buffers that have filenames but no corresponding file on disk, even when using ++p flag. Solution: allow update to write when buffer has filename but file doesn't exist.
* test: improve test conventionsdundargoc2024-04-23
| | | | | | | | | Specifically, functions that are run in the context of the test runner are put in module `test/testutil.lua` while the functions that are run in the context of the test session are put in `test/functional/testnvim.lua`. Closes https://github.com/neovim/neovim/issues/27004.
* refactor(test): inject after_each differentlyLewis Russell2024-04-10
|
* test: improve test conventionsdundargoc2024-04-08
| | | | Work on https://github.com/neovim/neovim/issues/27004.
* test: rename (meths, funcs) -> (api, fn)Lewis Russell2024-01-12
|
* test: typing for helpers.methsLewis Russell2024-01-12
|
* test: use vim.mpack and vim.uv directlyLewis Russell2024-01-12
|
* refactor: format test/*Justin M. Keyes2024-01-03
|
* refactor(options): deprecate nvim[_buf|_win]_[gs]et_optionLewis Russell2023-05-21
| | | | | Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: famiu <famiuhaque@protonmail.com>
* test: replace lfs with luv and vim.fsdundargoc2023-04-04
| | | | | | test: replace lfs with luv luv already pretty much does everything lfs does, so this duplication of dependencies isn't needed.
* test: simplify platform detection (#21020)dundargoc2022-11-22
| | | | | Extend the capabilities of is_os to detect more platforms such as freebsd and openbsd. Also remove `iswin()` helper function as it can be replaced by `is_os("win")`.
* test: introduce skip() #21010dundargoc2022-11-13
| | | | | | | This is essentially a convenience wrapper around the `pending()` function, similar to `skip_fragile()` but more general-purpose. Also remove `pending_win32` function as it can be replaced by `skip(iswin())`.
* feat: ":write ++p" creates parent dirs #20835Victor Blanchard2022-11-06
| | | | | | | | | | | - `:write ++p foo/bar/baz.txt` should create parent directories `foo/bar/` if they do not exist - Note: `:foo ++…` is usually for options. No existing options have a single-char abbreviation (presumably by design), so it's safe to special-case `++p` here. - Same for `writefile(…, 'foo/bar/baz.txt', 'p')` - `BufWriteCmd` can see the ++p flag via `v:cmdarg`. closes #19884
* ci: add cirrus to isCI function to skip tests (#20526)dundargoc2022-10-17
| | | | The environment variable CIRRUS_CI is manually passed to RunTests.cmake as it doesn't get passed when using cmake script mode.
* ci: move BSD jobs from sourcehut to Cirrus CI #19616dundargoc2022-09-08
| | | | | | | | | | | | | | | | | | | dispatch.sr.ht is being deprecated, meaning that using sourcehut CI won't be possible (see https://github.com/neovim/neovim/issues/19609). Since Github Actions doesn't provide any BSD runners an external service is required and Cirrus CI seems like a good replacement for sourcehut. Initially experimented with using FreeBSD and OpenBSD virtual machines in GitHub Actions, but Cirrus has been a much better fit with better performance, logs and overall experience. Failing tests are automatically skipped on FreeBSD regardless if it's on CI or not. Ideally these tests should only be skipped in CI with the help of `isCI` helper function. Unfortunately, the tests don't recognize the environment variable CIRRUS_CI even if it's set manually. This workaround is good enough for the time being, but we might want to only skip tests when using the CI (or even better, fix the failing tests). Closes: https://github.com/neovim/neovim/issues/19609
* refactor(tests): remove redir_exec #15718Justin M. Keyes2021-09-19
| | | | | | | | | | | Problem - `redir_exec` is obsolete, but it keeps getting used in new tests because people copy existing tests. - Disadvantages of `redir_exec`: - Captures extra junk before the actual error/message that we _want_ to test. - Does not fail on error, unlike e.g. `command()`. Solution - Use new functions like `nvim_exec` and `pcall_err`.
* tests: fix non-controversial misuse of `pending` (#11247)Daniel Hahler2019-10-18
| | | Ref: https://github.com/neovim/neovim/pull/11184
* fixup: always delete Xfile, fix exit code checkJan Edmund Lazo2018-05-25
| | | | | after_each + os.remove ensures Xfile is deleted after every test. Windows exit code is inconsistent.
* win: test: don't test symlink if not admin userJan Edmund Lazo2018-05-24
|
* win: test: disable non-admin failing testsJan Edmund Lazo2018-05-24
| | | | | | | mkfifo (msysgit) does not work outside of msys2 environment. gzip tests fail on Windows. mklink requires admin privs for file symbolic links so mklink fails.
* Resolve issues mentioned in PR reviewJan Edmund Lazo2018-02-19
|
* test: enable ex_cmds/write_spec.lua in WindowsJan Edmund Lazo2018-02-19
|
* functests: Fix linter errorsZyX2017-04-09
|
* functests: Replace execute with either command or feed_commandZyX2017-04-09
| | | | | | | | | | Hope this will make people using feed_command less likely: this hides bugs. Already found at least two: 1. msgpackparse() will show internal error: hash_add() in case of duplicate keys, though it will still work correctly. Currently silenced. 2. ttimeoutlen was spelled incorrectly, resulting in option not being set when expected. Test was still functioning somehow though. Currently fixed.
* functests: Test some :write errorsZyX2017-04-03
|
* os_nodetype: open fd with O_NONBLOCK (#5515)Justin M. Keyes2016-10-21
| | | | | Closes #5267 Helped-by: oni-link <knil.ino@gmail.com>
* Mark some functional tests as pending in WindowsRui Abreu Ferreira2016-08-26
|
* test: fix command_count_specBjörn Linse2016-06-23
| | | | The test hit wait_return if x or .x.swp exists in the project root directory.
* test: functional: Remove test_bkc_* files after testingJames McCoy2016-06-15
|
* functests: Check logs in lua codeZyX2016-06-10
| | | | | | It is otherwise impossible to determine which test failed sanitizer/valgrind check. test/functional/helpers.lua module return was changed so that tests which do not provide after_each function to get new check will automatically fail.
* Remove old UNIX ifdef from buf_write()Rui Abreu Ferreira2016-04-28
When backupcopy=auto buf_write assumes backupcopy=yes when the file is a hard/symbolic link. However this check was guarded by a UNIX ifdef. The check itself is portable and the guard can be removed. Added a couple tests to check the behaviour of bkc=auto and bkc=no with a symbolic link. Reported in #4525