浏览代码

Tests: Teach Server test to wait for server exit

We expect the server to exit when its communication pipes are closed.
Close them and wait for the server to exit.  If supported by the current
version of python, kill the server if it does not exit after a few
seconds.
Brad King 9 年之前
父节点
当前提交
d56f9237d7
共有 1 个文件被更改,包括 14 次插入0 次删除
  1. 14 0
      Tests/Server/server-test.py

+ 14 - 0
Tests/Server/server-test.py

@@ -102,4 +102,18 @@ for obj in testData:
 
     print("Completed")
 
+# Tell the server to exit.
+proc.stdin.close()
+proc.stdout.close()
+
+# Wait for the server to exit.
+# If this version of python supports it, terminate the server after a timeout.
+try:
+    proc.wait(timeout=5)
+except TypeError:
+    proc.wait()
+except:
+    proc.terminate()
+    raise
+
 sys.exit(0)