summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/stdlib/osproctest.nim8
-rw-r--r--tests/stdlib/tosproc.nim24
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/stdlib/osproctest.nim b/tests/stdlib/osproctest.nim
new file mode 100644
index 000000000..8c4fba9ba
--- /dev/null
+++ b/tests/stdlib/osproctest.nim
@@ -0,0 +1,8 @@
+# This is test program for the osproc module.
+
+import os
+
+echo getCurrentDir()
+
+for i in 1..paramCount():
+  echo paramStr(i)
diff --git a/tests/stdlib/tosproc.nim b/tests/stdlib/tosproc.nim
new file mode 100644
index 000000000..ac129e709
--- /dev/null
+++ b/tests/stdlib/tosproc.nim
@@ -0,0 +1,24 @@
+discard """
+  file: "tospaths.nim"
+  output: ""
+"""
+# test the osproc module
+
+import os, osproc
+
+block execProcessTest:
+  let dir = parentDir(currentSourcePath())
+  let (outp, err) = execCmdEx("nim c " & quoteShell(dir / "osproctest.nim"))
+  doAssert err == 0
+  let exePath = dir / addFileExt("osproctest", ExeExt)
+  let outStr1 = execProcess(exePath, workingDir=dir, args=["foo", "b A r"], options={})
+  doAssert outStr1 == dir & "\nfoo\nb A r\n"
+
+  const testDir = "t e st"
+  createDir(testDir)
+  doAssert dirExists(testDir)
+  let outStr2 = execProcess(exePath, workingDir=testDir, args=["x yz"], options={})
+  doAssert outStr2 == absolutePath(testDir) & "\nx yz\n"
+
+  removeDir(testDir)
+  removeFile(exePath)