summary refs log tree commit diff stats
path: root/tests/osproc/tstdin.nim
blob: d94c34192dfdc5349e404b53b5c1dfee4ff41aed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
discard """
  file: "tstdin.nim"
  output: "10"
"""
import osproc, os, streams

const filename = when defined(Windows): "ta_in.exe" else: "ta_in"

doAssert fileExists(getCurrentDir() / "tests" / "osproc" / filename)

var p = startProcess(filename, getCurrentDir() / "tests" / "osproc")
p.inputStream.write("5\n")
p.inputStream.flush()
while true:
  let line = p.outputStream.readLine()
  if line != "":
    echo line
  else:
    break