merged #8624 manually; fixes #8442; closes #8575

This commit is contained in:
Araq 2018-08-31 11:19:33 +02:00
commit bacf08e65d
2 changed files with 36 additions and 2 deletions

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

@ -0,0 +1,32 @@
discard """
output: '''--------------------------------------
to stderr
to stderr
--------------------------------------
'''
"""
import osproc, os, streams
const filename = "ta_out".addFileExt(ExeExt)
doAssert fileExists(getCurrentDir() / "tests" / "osproc" / filename)
var p = startProcess(filename, getCurrentDir() / "tests" / "osproc",
options={})
try:
let stdoutStream = p.outputStream
let stderrStream = p.errorStream
var x = newStringOfCap(120)
var output = ""
while stderrStream.readLine(x.TaintedString):
output.add(x & "\n")
echo "--------------------------------------"
stdout.flushFile()
stderr.write output
stderr.flushFile()
echo "--------------------------------------"
stdout.flushFile()
finally:
p.close()