tstdout.nim 741 B

1234567891011121314151617181920212223242526272829303132
  1. discard """
  2. output: '''--------------------------------------
  3. start ta_out
  4. to stdout
  5. to stdout
  6. to stderr
  7. to stderr
  8. to stdout
  9. to stdout
  10. end ta_out
  11. --------------------------------------
  12. '''
  13. """
  14. import osproc, os, streams
  15. const filename = when defined(Windows): "ta_out.exe" else: "ta_out"
  16. doAssert fileExists(getCurrentDir() / "tests" / "osproc" / filename)
  17. var p = startProcess(filename, getCurrentDir() / "tests" / "osproc",
  18. options={poStdErrToStdOut})
  19. let outputStream = p.outputStream
  20. var x = newStringOfCap(120)
  21. var output = ""
  22. while outputStream.readLine(x.TaintedString):
  23. output.add(x & "\n")
  24. echo "--------------------------------------"
  25. stdout.write output
  26. echo "--------------------------------------"