treadlines.nim 571 B

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