From b348661222b3c3b29462e36770114ef651c447d8 Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Thu, 12 Feb 2015 15:14:30 -0600 Subject: [PATCH] If there is an error running pytest, mark job as dead Signed-off-by: Andrew Schoen --- teuthology/task/tests/__init__.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/teuthology/task/tests/__init__.py b/teuthology/task/tests/__init__.py index ba7dea8f86..bbed7e26a9 100644 --- a/teuthology/task/tests/__init__.py +++ b/teuthology/task/tests/__init__.py @@ -74,15 +74,21 @@ def task(ctx, config): and then executing them with the teuthology ctx and config args. Your tests must follow standard pytest conventions to be discovered. """ - status = pytest.main( - args=[ - '-q', - '--pyargs', __name__ - ], - plugins=[TeuthologyContextPlugin(ctx, config)] - ) - if status == 0: - log.info("OK. All tests passed!") + try: + status = pytest.main( + args=[ + '-q', + '--pyargs', __name__ + ], + plugins=[TeuthologyContextPlugin(ctx, config)] + ) + except Exception: + log.exception("Saw failure running pytest") + ctx.summary["status"] = "dead" else: - log.error("FAIL. Saw test failures...") - ctx.summary["status"] = "fail" + if status == 0: + log.info("OK. All tests passed!") + ctx.summary["status"] = "pass" + else: + log.error("FAIL. Saw test failures...") + ctx.summary["status"] = "fail" -- 2.39.5