summary refs log tree commit diff stats
path: root/tests/stdlib/tosproc.nim
blob: ac129e709c4324a45d8ff460606d06ef93bc5227 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)