diff options
author | Araq <rumpf_a@web.de> | 2018-08-31 11:19:33 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-08-31 11:19:42 +0200 |
commit | bacf08e65d614f515b0feb73e549090dce012f3f (patch) | |
tree | 46e3e7140302a1dc97f440cb3b37f6dd17c0ddf3 /tests/osproc | |
parent | 47c7fd037ed28b7de3d120b003d059d30e18f128 (diff) | |
download | Nim-bacf08e65d614f515b0feb73e549090dce012f3f.tar.gz |
merged #8624 manually; fixes #8442; closes #8575
Diffstat (limited to 'tests/osproc')
-rw-r--r-- | tests/osproc/tstderr.nim | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/osproc/tstderr.nim b/tests/osproc/tstderr.nim new file mode 100644 index 000000000..7a39522a3 --- /dev/null +++ b/tests/osproc/tstderr.nim @@ -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() |