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.
Problem:
`vim.fs.dirname([[C:\User\XXX\AppData\Local]])` returns "." on
mingw/msys2.
Solution:
- Check for "mingw" when deciding `iswin`.
- Use `has("win32")` where possible, it works in "fast" contexts since
b02eeb6a72.
- `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.
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 d34c64e342, but this wasn't
noticed until 96128a5076 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
Problem:
Since 96128a5076 the test logs have noise from tests that *expect*
failures:
$NVIM_LOG_FILE: /tmp/cirrus-ci-build/build/.nvimlog
(last 100 lines)
ERR 2024-09-04T13:38:45.181 T949.28335.0/c terminfo_start:486: uv_pipe_open failed: no such device or address
ERR 2024-09-04T13:38:45.181 T949.28335.0/c flush_buf:2527: uv_write failed: bad file descriptor
ERR 2024-09-04T13:38:45.181 T949.28335.0/c flush_buf:2527: uv_write failed: bad file descriptor
WRN 2024-09-04T13:43:43.294 ?.35904 server_start:173: Failed to start server: address already in use: /…/Xtest_tmpdir/…/T7159.35895.0
WRN 2024-09-04T13:43:43.314 ?.35907 server_start:173: Failed to start server: illegal operation on a directory: /
ERR 2024-09-04T13:43:43.332 ?.35909 socket_watcher_init:60: Host lookup failed: https://example.com
Solution:
Rewrite the test to use `vim.system()`. Set NVIM_LOG_FILE in the child
process to a "throwaway" logfile.
Problem:
137f98cf64 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.
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.