tstderr.nim 816 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. discard """
  2. output: '''
  3. start tstderr
  4. --------------------------------------
  5. to stderr
  6. to stderr
  7. --------------------------------------
  8. '''
  9. """
  10. echo "start tstderr"
  11. import osproc, os, streams
  12. const filename = "ta_out".addFileExt(ExeExt)
  13. doAssert fileExists(getCurrentDir() / "tests" / "osproc" / filename)
  14. var p = startProcess(filename, getCurrentDir() / "tests" / "osproc",
  15. options={})
  16. try:
  17. let stdoutStream = p.outputStream
  18. let stderrStream = p.errorStream
  19. var x = newStringOfCap(120)
  20. var output = ""
  21. while stderrStream.readLine(x.TaintedString):
  22. output.add(x & "\n")
  23. echo "--------------------------------------"
  24. stdout.flushFile()
  25. stderr.write output
  26. stderr.flushFile()
  27. echo "--------------------------------------"
  28. stdout.flushFile()
  29. finally:
  30. p.close()