mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-06 20:04:18 +00:00
osproc.execCmdEx now takes an optional input for stdin, env, workingDir (#14211)
* `osproc.execCmdEx` now takes an optional `input` for stdin * execCmdEx now also takes an optional ``workingDir` and `env`
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# test the osproc module
|
||||
|
||||
import stdtest/specialpaths
|
||||
import "../.." / compiler/unittest_light
|
||||
import "$nim" / compiler/unittest_light
|
||||
|
||||
when defined(case_testfile): # compiled test file for child process
|
||||
from posix import exitnow
|
||||
@@ -119,3 +119,16 @@ else:
|
||||
|
||||
var result = startProcessTest("nim r --hints:off -", options = {}, input = "echo 3*4")
|
||||
doAssert result == ("12\n", 0)
|
||||
|
||||
import std/strtabs
|
||||
block execProcessTest:
|
||||
var result = execCmdEx("nim r --hints:off -", options = {}, input = "echo 3*4")
|
||||
stripLineEnd(result[0])
|
||||
doAssert result == ("12", 0)
|
||||
doAssert execCmdEx("ls --nonexistant").exitCode != 0
|
||||
when false:
|
||||
# bug: on windows, this raises; on posix, passes
|
||||
doAssert execCmdEx("nonexistant").exitCode != 0
|
||||
when defined(posix):
|
||||
doAssert execCmdEx("echo $FO", env = newStringTable({"FO": "B"})) == ("B\n", 0)
|
||||
doAssert execCmdEx("echo $PWD", workingDir = "/") == ("/\n", 0)
|
||||
|
||||
Reference in New Issue
Block a user