Merge #9686 'win/Lua: monkey-patch os.getenv()'

fixes #9681
This commit is contained in:
Justin M. Keyes
2019-03-16 20:28:52 +01:00
4 changed files with 86 additions and 21 deletions

View File

@@ -300,3 +300,19 @@ describe('package.path/package.cpath', function()
eq(new_paths_str, eval_lua('package.path'):sub(1, #new_paths_str))
end)
end)
describe('os.getenv', function()
it('returns nothing for undefined env var', function()
eq(NIL, funcs.luaeval('os.getenv("XTEST_1")'))
end)
it('returns env var set by the parent process', function()
local value = 'foo'
clear({env = {['XTEST_1']=value}})
eq(value, funcs.luaeval('os.getenv("XTEST_1")'))
end)
it('returns env var set by let', function()
local value = 'foo'
meths.command('let $XTEST_1 = "'..value..'"')
eq(value, funcs.luaeval('os.getenv("XTEST_1")'))
end)
end)