diff options
author | c-blake <c-blake@users.noreply.github.com> | 2020-10-01 12:06:38 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-01 18:06:38 +0200 |
commit | 26d656e73e2354bc6f177073b948a7791e8f7427 (patch) | |
tree | f9c71e406db77778e9543838f1b6b54e391e9513 /tests/osproc/treadlines.nim | |
parent | 531ed2dc365d6d33c7bccdfbe22df561cf14af86 (diff) | |
download | Nim-26d656e73e2354bc6f177073b948a7791e8f7427.tar.gz |
Add first draft of new osproc.readLines (#15429)
* Add first draft of new osproc.readLines * Add test for new osproc.readLines * Rename test to start w/t to run; Also add newline to output * Suppress hint messages. * Output should match this time. * Shoulda picked a program with simpler syntax than ..lol * Address https://github.com/nim-lang/Nim/pull/15429#issuecomment-701890898 and https://github.com/nim-lang/Nim/pull/15429#issuecomment-701985976 by factoring `readLines` into `iterator lines` and a wrapper `proc`. * Address https://github.com/nim-lang/Nim/pull/15429#issuecomment-702127289 and also add a `ReadIOEffect` tag to the iterator (called by the wrapper.. so it should need no separate tag, if I understand correctly).
Diffstat (limited to 'tests/osproc/treadlines.nim')
-rw-r--r-- | tests/osproc/treadlines.nim | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/osproc/treadlines.nim b/tests/osproc/treadlines.nim new file mode 100644 index 000000000..3a8303321 --- /dev/null +++ b/tests/osproc/treadlines.nim @@ -0,0 +1,20 @@ +discard """ + output: '''Error: cannot open 'a.nim' +Error: cannot open 'b.nim' +''' + targets: "c" +""" + +import osproc + +var ps: seq[Process] # compile & run 2 progs in parallel +for prog in ["a", "b"]: + ps.add startProcess("nim", "", + ["r", "--hint[Conf]=off", "--hint[Processing]=off", prog], + options = {poUsePath, poDaemon, poStdErrToStdOut}) + +for p in ps: + let (lines, exCode) = p.readLines + if exCode != 0: + for line in lines: echo line + p.close |