tests: configurable timeout for run_python/isolated
This commit is contained in:
@@ -302,7 +302,7 @@ def get_database_auth():
|
|||||||
return retval
|
return retval
|
||||||
|
|
||||||
|
|
||||||
def run_python(path, env=None, args=None):
|
def run_python(path, env=None, args=None, timeout=None):
|
||||||
new_argv = [sys.executable]
|
new_argv = [sys.executable]
|
||||||
new_env = os.environ.copy()
|
new_env = os.environ.copy()
|
||||||
if path:
|
if path:
|
||||||
@@ -323,17 +323,19 @@ def run_python(path, env=None, args=None):
|
|||||||
stdin=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
)
|
)
|
||||||
|
if timeout is None:
|
||||||
|
timeout = 10
|
||||||
try:
|
try:
|
||||||
output, _ = p.communicate(timeout=30)
|
output, _ = p.communicate(timeout=timeout)
|
||||||
except subprocess.TimeoutExpired:
|
except subprocess.TimeoutExpired:
|
||||||
p.kill()
|
p.kill()
|
||||||
output, _ = p.communicate(timeout=30)
|
output, _ = p.communicate(timeout=timeout)
|
||||||
return "{0}\nFAIL - timed out".format(output)
|
return "{0}\nFAIL - timed out".format(output)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
def run_isolated(path, prefix='tests/isolated/', env=None, args=None):
|
def run_isolated(path, prefix='tests/isolated/', env=None, args=None, timeout=None):
|
||||||
output = run_python(prefix + path, env=env, args=args).rstrip()
|
output = run_python(prefix + path, env=env, args=args, timeout=timeout).rstrip()
|
||||||
if output.startswith(b'skip'):
|
if output.startswith(b'skip'):
|
||||||
parts = output.split(b':', 1)
|
parts = output.split(b':', 1)
|
||||||
skip_args = []
|
skip_args = []
|
||||||
|
Reference in New Issue
Block a user