summary refs log tree commit diff stats
path: root/tests/osproc/texitcode.nim
blob: 0b05ca3cbbf0e262511b5a367249c8d42765166d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
discard """
  output: ""
"""

import osproc, os

const filename = when defined(Windows): "tafalse.exe" else: "tafalse"
let dir = getCurrentDir() / "tests" / "osproc"
doAssert fileExists(dir / filename)

var p = startProcess(filename, dir)
doAssert(waitForExit(p) == QuitFailure)

p = startProcess(filename, dir)
var running = true
while running:
  running = running(p)
doAssert(waitForExit(p) == QuitFailure)

# make sure that first call to running() after process exit returns false
p = startProcess(filename, dir)
for j in 0..<30: # refs #13449
  os.sleep(50)
  if not running(p): break
doAssert(not running(p))
doAssert(waitForExit(p) == QuitFailure) # avoid zombies