mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00

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.
28 lines
814 B
Lua
28 lines
814 B
Lua
local t = require('test.testutil')
|
|
local n = require('test.functional.testnvim')()
|
|
|
|
local eq = t.eq
|
|
local clear = n.clear
|
|
local exec_capture = n.exec_capture
|
|
local command = n.command
|
|
|
|
describe('vim.uv', function()
|
|
before_each(function()
|
|
clear()
|
|
end)
|
|
|
|
-- Subsequential env var assignment consistency
|
|
-- see: issue 32550
|
|
it('vim.uv.os_setenv(), vim.uv.os_unsetenv() consistency', function()
|
|
eq('', exec_capture('echo $FOO'))
|
|
command('lua vim.uv.os_setenv("FOO", "bar")')
|
|
eq('bar', exec_capture('echo $FOO'))
|
|
command('lua vim.uv.os_setenv("FOO", "fizz")')
|
|
eq('fizz', exec_capture('echo $FOO'))
|
|
command('lua vim.uv.os_unsetenv("FOO")')
|
|
eq('', exec_capture('echo $FOO'))
|
|
command('lua vim.uv.os_setenv("FOO", "buzz")')
|
|
eq('buzz', exec_capture('echo $FOO'))
|
|
end)
|
|
end)
|