summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorJohannes Hofmann <johannes.hofmann@gmx.de>2016-09-30 10:27:59 +0200
committerJohannes Hofmann <johannes.hofmann@gmx.de>2016-09-30 10:27:59 +0200
commit8d85809d626e7445889c9f398682147cc5544950 (patch)
tree3c29aedd8f7ac804a8105b6641708c0db28b3c9b /tests
parent52db21bb2cb03b498b0cb3b34a49213449b34b2e (diff)
downloadNim-8d85809d626e7445889c9f398682147cc5544950.tar.gz
add testcase for exit code handling
Diffstat (limited to 'tests')
-rw-r--r--tests/osproc/texitcode.nim18
-rw-r--r--tests/osproc/tfalse.nim2
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/osproc/texitcode.nim b/tests/osproc/texitcode.nim
new file mode 100644
index 000000000..df1db8aa3
--- /dev/null
+++ b/tests/osproc/texitcode.nim
@@ -0,0 +1,18 @@
+discard """
+  file: "texitcode.nim"
+  output: ""
+"""
+import osproc, os
+
+const filename = when defined(Windows): "tfalse.exe" else: "tfalse"
+
+doAssert fileExists(getCurrentDir() / "tests" / "osproc" / filename)
+
+var p = startProcess(filename, getCurrentDir() / "tests" / "osproc")
+doAssert(waitForExit(p) == QuitFailure)
+
+p = startProcess(filename, getCurrentDir() / "tests" / "osproc")
+var running = true
+while running:
+  running = running(p)
+doAssert(waitForExit(p) == QuitFailure)
diff --git a/tests/osproc/tfalse.nim b/tests/osproc/tfalse.nim
new file mode 100644
index 000000000..a2c5e259d
--- /dev/null
+++ b/tests/osproc/tfalse.nim
@@ -0,0 +1,2 @@
+import system
+quit(QuitFailure)