aboutsummaryrefslogtreecommitdiff
path: root/test/functional/core/fileio_spec.lua
Commit message (Collapse)AuthorAge
* 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.
* fix(tests): needing two calls to setup a screen is cringebfredl2024-11-14
| | | | | | | | | | Before calling "attach" a screen object is just a dummy container for (row, col) values whose purpose is to be sent as part of the "attach" function call anyway. Just create the screen in an attached state directly. Keep the complete (row, col, options) config together. It is still completely valid to later detach and re-attach as needed, including to another session.
* 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
* test: tmpname(create:boolean) #30242Justin M. Keyes2024-09-03
| | | | | | | | | Problem: 137f98cf6428 added the `create` parameter to `tmpname()` but didn't fully implement it. Solution: - Update impl for the `os.tmpname()` codepath. - Inspect all usages of `tmpname()`, update various tests.
* refactor(tests): more global highlight definitionsbfredl2024-05-26
|
* 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(lua): deprecate tbl_flattenJustin M. Keyes2024-04-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Besides being redundant with vim.iter():flatten(), `tbl_flatten` has these problems: - Has `tbl_` prefix but only accepts lists. - Discards some results! Compare the following: - iter.flatten(): ``` vim.iter({1, { { a = 2 } }, { 3 } }):flatten():totable() ``` - tbl_flatten: ``` vim.tbl_flatten({1, { { a = 2 } }, { 3 } }) ``` Solution: Deprecate tbl_flatten. Note: iter:flatten() currently fails ("flatten() requires a list-like table") on this code from gen_lsp.lua: local anonym = vim.iter({ -- remove nil anonymous_num > 1 and '' or nil, '---@class ' .. anonymous_classname, }):flatten():totable() Should we enhance :flatten() to work for arrays?
* 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: remove helpers.sleep()Lewis Russell2024-01-12
|
* test: do not inject vim module into global helpersLewis Russell2024-01-12
|
* refactor: format test/*Justin M. Keyes2024-01-03
|
* test: avoid repeated screen lines in expected stateszeertzjq2023-12-09
| | | | | | This is the command invoked repeatedly to make the changes: :%s/^\(.*\)|\%(\*\(\d\+\)\)\?$\n\1|\%(\*\(\d\+\)\)\?$/\=submatch(1)..'|*'..(max([str2nr(submatch(2)),1])+max([str2nr(submatch(3)),1]))/g
* test: unreliable 'nofsync' test #26423Justin M. Keyes2023-12-06
| | | | | | | | | | | | | | | | Followup to 27501d3b6a8d577cf3f5ecc3fe9e219f477586b7. Problem: CI sometimes fails. Something is triggering an extra fsync(). FAILED test/functional/core/fileio_spec.lua @ 52: fileio fsync() with 'nofsync' #8304 test/functional/core/fileio_spec.lua:100: Expected objects to be the same. Passed in: (number) 5 Expected: (number) 4 Solution: Relax the assertion.
* test: 'nofsync' with deadly signal #26415Justin M. Keyes2023-12-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: The test for 'nofsync' swapfile preservation on a deadly signal, does not actually assert anything. followup to 1fd29a28841dee3d25ff079eb24fc160eb02cb3c Solution: Check that swapfile contents are present after getting SIGTERM. TODO: this doesn't really verify that 'fsync' was called; it still passes with this patch: diff --git a/src/nvim/main.c b/src/nvim/main.c index 216e39f3e81c..7a635520401d 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -838,7 +838,7 @@ void preserve_exit(const char *errmsg) if (errmsg != NULL) { os_errmsg("Vim: preserving files...\r\n"); } - ml_sync_all(false, false, true); // preserve all swap files + ml_sync_all(false, false, false); // preserve all swap files break; } } However it correctly fails with this patch, at least: diff --git a/src/nvim/main.c b/src/nvim/main.c index 216e39f3e81c..f2306c310ddc 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -838,7 +838,6 @@ void preserve_exit(const char *errmsg) if (errmsg != NULL) { os_errmsg("Vim: preserving files...\r\n"); } - ml_sync_all(false, false, true); // preserve all swap files break; } }
* test: fileio_spec is unreliable/flaky #26404Justin M. Keyes2023-12-05
| | | | | | | | | | | | | | | | | | | | Problem: CI sometimes fails. Something is triggering an extra fsync(). FAILED test/functional/core/fileio_spec.lua @ 52: fileio fsync() codepaths #8304 test/functional/core/fileio_spec.lua:87: Expected objects to be the same. Passed in: (number) 3 Expected: (number) 2 stack traceback: test/functional/core/fileio_spec.lua:87: in function <test/functional/core/fileio_spec.lua:52> Solution: Relax the assertion to `fsync >= 2` instead of exactly 2. (Note this is not a behavior change: the next assertion has always checked `fsync == 4`, it's just that the intermediate 3rd fsync was never explicitly asserted.)
* fix(defaults): set 'fsync' #26034Ploum2023-11-14
| | | | | | | | Problem: 'nofsync' may lose data if the system has a hard shutdown. #9888 Solution: Change default to 'fsync'. This may be revisited in the future when 'nofsync' can be made safer.
* refactor(message): simplify msg_puts_display and use batched grid updatesbfredl2023-10-03
| | | | | | | | | msg_puts_display was more complex than necessary in nvim, as in nvim, it no longer talks directly with a terminal. In particular we don't need to scroll the grid before emiting the last char. The TUI already takes care of things like that, for terminals where it matters.
* test(fileio_spec): fix files not cleaned up properly (#25483)zeertzjq2023-10-03
|
* feat: NVIM_APPNAME supports relative paths #25233Rory Nesbitt2023-09-27
| | | | | | | | | | | | | | Problem: NVIM_APPNAME does not allow path separators in the name, so relative paths can't be used: NVIM_APPNAME="neovim-configs/first-config" nvim NVIM_APPNAME="neovim-configs/second-config" nvim Solution: Let NVIM_APPNAME be a relative path. Absolute paths are not supported. fix #23056 fix #24966
* feat(options)!: remove compatible behaviours for vim 5.0 and earlierLewis Russell2023-07-17
|
* test(fs): vim.loop was renamed to vim.uv (#24376)kylo2522023-07-17
| | | test(fs): vim.loop has been replaced with vim.uv
* test(fs): get tmpdir robustly #23021kylo2522023-07-16
| | | | | | | | Problem: helpers.tmpname() may create a local file, depending on circumstances. Solution: Only use helpers.tmpname() for its parent directory (the "temp root"). Use fs_mkdtemp() to actually get a unique name.
* 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.
* feat: try to recover from missing tempdir #22573Justin M. Keyes2023-03-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: If vim_tempdir mysteriously goes missing (typically by "antivirus" on Windows), any plugins using tempname() will be broken for the rest of the session. #1432 #9833 https://groups.google.com/g/vim_use/c/ef55jNm5czI Steps: mkdir foo TMPDIR=./foo nvim :echo tempname() !rm -r foo :echo tempname() tempname() still uses the foo path even though it was deleted. Solution: - Don't assume that vim_tempdir exists. - If it goes missing once, retry vim_mktempdir and log (silently) an error. - If it goes missing again, retry vim_mktempdir and show an error. Rejected in Vim for performance reasons: https://groups.google.com/g/vim_use/c/qgRob9SWDv8/m/FAOFVVcDTv0J https://groups.google.com/g/vim_dev/c/cogp-Vye4oo/m/d_SVFXBbnnoJ But, logging shows that `vim_gettempdir` is not called frequently. Fixes #1432 Fixes #9833 Fixes #11250 Related: stdpath("run") f50135a32e11c535e1dc3a8e9460c5b4e640ee86
* refactor(tests): lift retry() into assert_log()Justin M. Keyes2023-01-17
|
* test(fileio_spec): avoid expect_exit() without calling clear() (#21810)zeertzjq2023-01-15
| | | | | Since before_each() doesn't call clear() in these tests, after_each() may call expect_exit() without calling clear() if a test is skipped, causing frequent test failures on Cirrus CI. Close the session instead.
* docs: fix typos (#21196)dundargoc2022-11-29
| | | | | Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: Raphael <glephunter@gmail.com> Co-authored-by: Gregory Anders <greg@gpanders.com>
* 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())`.
* fix(fileio): use first available directory in backupdir for backupcopy (#20655)Will Spurgin2022-11-05
| | | | | | | | | | | | | | | Fix backups failing for symlink files Set backup to NULL prior to continuing & Clear backup prior to NULL set to avoid leaking Fixes #11349 Remove testing hacks in scripts for windows Skip FreeBSD Something appears up with these types of tests for FreeBSD on Circus, see 2d6735d8ce
* 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.
* feat(messages)!: graduate the 'msgsep' featurebfredl2022-10-05
| | | | | | | The old behaviour (e.g. via `set display-=msgsep`) will not be available. Assuming that messages always are being drawn on msg_grid (or not drawn at all, and forwarded to `ext_messages` enabled UI) will allows some simplifcations and enhancements moving forward.
* feat: ":write!" skips "file changed" warning #18665Louis Sven Goulet2022-09-24
| | | | | | | | | | Problem: Cannot opt-out of "WARNING: The file has been changed since reading it!!!", even with ":write!". Solution: Change ":write!" to skip the warning. closes #7270
* 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
* feat: stdpath('run'), /tmp/nvim.user/ #18993Justin M. Keyes2022-06-30
| | | | | | | | | | | | | | | | Problem: - Since c57f6b28d71d #8519, sockets are created in ~/.local/… but XDG spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which implies that XDG_STATE_DIR is potentially non-local. - Not easy to inspect Nvim-created temp files (for debugging etc). Solution: - Store sockets in stdpath('run') ($XDG_RUNTIME_DIR). - Establish "/tmp/nvim.user/" as the tempdir root shared by all Nvims. - Make ok() actually useful. - Introduce assert_nolog(). closes #3517 closes #17093
* fix(tests): check for EOF on exit of nvim properlybfredl2022-06-13
|
* fix(fileio): replace characters over INT_MAX with U+FFFD (#16354)Javier Lopez2021-11-23
| | | | fixes #11877 credit: @zubairabid https://github.com/neovim/neovim/pull/12010
* vim-patch:8.1.0251: support full paths for 'backupdir' #11269Joe Hermaszewski2019-11-17
| | | | | | | Problem: Using a full path is supported for 'directory' but not for 'backupdir'. (Mikolaj Machowski) Solution: Support 'backupdir' as well. (Christian Brabandt, closes vim/vim#179) https://github.com/vim/vim/commit/b782ba475a3f8f2b0be99dda164ba4545347f60f
* os/fs: introduce os_fopen()Justin M. Keyes2019-07-25
| | | | | | | Windows: Using fopen() directly may need UTF-16 filepath conversion. To achieve that, os_fopen() goes through os_open(). fix #10586
* Merge #9709 'fileio: use os_copy to create backups'Justin M. Keyes2019-05-20
|\ | | | | | | ref #8288
| * test: move trim to global helpersSaid Al Attrach2019-03-30
| |
| * test: make first attempt at some kind of testSaid Al Attrach2019-03-24
|/
* API: nvim__stats()Justin M. Keyes2018-04-24
| | | | Use it to verify fsync() behavior.
* test: fsync() codepathsJustin M. Keyes2018-04-23