Merge pull request #4500 from nigredo-tori/fix-osproc-env

Fix passing environment in startProcess (win)
This commit is contained in:
Andreas Rumpf 2016-07-20 09:27:14 +02:00 • committed by GitHub
commit 9e9ce6a4e3
3 changed files with 44 additions and 9 deletions

32
tests/osproc/passenv.nim Normal file
View file

@ -0,0 +1,32 @@
discard """
file: "passenv.nim"
output: "123"
targets: "c c++ objc"
"""
import osproc, os, strtabs
# Checks that the environment is passed correctly in startProcess
# To do that launches a copy of itself with a new environment.
if paramCount() == 0:
# Parent process
let env = newStringTable()
env["A"] = "1"
env["B"] = "2"
env["C"] = "3"
let p = startProcess(
getAppFilename(),
args = @["child"],
env = env,
options = {poStdErrToStdOut, poUsePath, poParentStreams}
)
discard p.waitForExit
else:
# Child process
# should output "123"
echo getEnv("A") & getEnv("B") & getEnv("C")