diff options
| author | Lewis Russell <lewis6991@gmail.com> | 2026-05-08 11:35:50 +0100 |
|---|---|---|
| committer | Lewis Russell <me@lewisr.dev> | 2026-05-13 13:14:07 +0100 |
| commit | 9432e6c1e2e93ffffabeeeaeb6ccc0cbdf9609dd (patch) | |
| tree | 71d9b00ddc4e384a36f820af016c7a2bca44d071 /src/nvim/lua/executor.c | |
| parent | 706cbbff330a853e14caf89ba50fde3cd44ce534 (diff) | |
| download | rneovim-9432e6c1e2e93ffffabeeeaeb6ccc0cbdf9609dd.tar.gz rneovim-9432e6c1e2e93ffffabeeeaeb6ccc0cbdf9609dd.tar.bz2 rneovim-9432e6c1e2e93ffffabeeeaeb6ccc0cbdf9609dd.zip | |
test: run Lua harness with nvim -l
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
Diffstat (limited to 'src/nvim/lua/executor.c')
| -rw-r--r-- | src/nvim/lua/executor.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 199813bf4a..c2b1887d60 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -601,6 +601,17 @@ static int nlua_check_interrupt(lua_State *lstate) return 1; } +static int nlua_os_exit(lua_State *lstate) +{ + int status = 0; + if (lua_gettop(lstate) >= 1 && !lua_isnil(lstate, 1)) { + status = lua_isboolean(lstate, 1) ? (lua_toboolean(lstate, 1) ? 0 : 1) + : (int)luaL_checkinteger(lstate, 1); + } + getout(status); + return 0; // Unreachable, but MSVC does not infer getout() is noreturn. +} + static nlua_ref_state_t *nlua_new_ref_state(lua_State *lstate, bool is_thread) FUNC_ATTR_NONNULL_ALL { @@ -841,6 +852,12 @@ static bool nlua_state_init(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL lua_pop(lstate, 1); #endif + // os.exit() + lua_getglobal(lstate, "os"); + lua_pushcfunction(lstate, &nlua_os_exit); + lua_setfield(lstate, -2, "exit"); + lua_pop(lstate, 1); + // vim lua_newtable(lstate); |