aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Filippov <alekseyf@google.com>2018-03-26 12:39:36 +0000
committerAleksey Filippov <alekseyf@google.com>2018-03-26 12:48:40 +0000
commitfa39e1082c7f718540da349f072b57f9b815aade (patch)
treebbd04b34143f1de9f421ea1e27f66c106077b3e6
parent8efd9400922f6f8eb876f9ef8d0042679d836c90 (diff)
downloadmeson-fa39e1082c7f718540da349f072b57f9b815aade.zip
meson-fa39e1082c7f718540da349f072b57f9b815aade.tar.gz
meson-fa39e1082c7f718540da349f072b57f9b815aade.tar.bz2
Timeout on test subprocesses instead of hanging and failing CI completely
-rwxr-xr-xrun_unittests.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/run_unittests.py b/run_unittests.py
index 0c84475..1546bc6 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -523,16 +523,18 @@ class BasePlatformTests(unittest.TestCase):
Run a command while printing the stdout and stderr to stdout,
and also return a copy of it
'''
- p = subprocess.Popen(command, stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT, env=os.environ.copy(),
- universal_newlines=True, cwd=workdir)
- output = p.communicate()[0]
- print(output)
+ # If this call hangs CI will just abort. It is very hard to distinguish
+ # between CI issue and test bug in that case. Set timeout and fail loud
+ # instead.
+ p = subprocess.run(command, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT, env=os.environ.copy(),
+ universal_newlines=True, cwd=workdir, timeout=60 * 5)
+ print(p.stdout)
if p.returncode != 0:
- if 'MESON_SKIP_TEST' in output:
+ if 'MESON_SKIP_TEST' in p.stdout:
raise unittest.SkipTest('Project requested skipping.')
raise subprocess.CalledProcessError(p.returncode, command)
- return output
+ return p.stdout
def init(self, srcdir, extra_args=None, default_args=True, inprocess=False):
self.assertPathExists(srcdir)