treadlines.nim 497 B

123456789101112131415161718192021
  1. discard """
  2. output: '''Error: cannot open 'a.nim'
  3. Error: cannot open 'b.nim'
  4. '''
  5. targets: "c"
  6. """
  7. import osproc
  8. var ps: seq[Process] # compile & run 2 progs in parallel
  9. for prog in ["a", "b"]:
  10. ps.add startProcess("nim", "",
  11. ["r", "--hint[Conf]=off", "--hint[Processing]=off", prog],
  12. options = {poUsePath, poDaemon, poStdErrToStdOut})
  13. for p in ps:
  14. let (lines, exCode) = p.readLines
  15. if exCode != 0:
  16. for line in lines: echo line
  17. p.close