summary refs log tree commit diff stats
path: root/tests/stdlib
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-05-13 04:45:36 -0700
committerGitHub <noreply@github.com>2020-05-13 13:45:36 +0200
commit041ee92bba0ba3f361218eb20ceeeee6eec85f91 (patch)
tree1a55acb85d5a9d15f836aaa1a0930193bdebf17c /tests/stdlib
parent1648f1dd9955c848f8fbaf46a89798ece21460cc (diff)
downloadNim-041ee92bba0ba3f361218eb20ceeeee6eec85f91.tar.gz
`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`
Diffstat (limited to 'tests/stdlib')
-rw-r--r--tests/stdlib/tosproc.nim15
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/stdlib/tosproc.nim b/tests/stdlib/tosproc.nim
index 73cec0cb7..36afd6a23 100644
--- a/tests/stdlib/tosproc.nim
+++ b/tests/stdlib/tosproc.nim
@@ -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)