diff --git a/lib/spack/spack/install_test.py b/lib/spack/spack/install_test.py index dbc1ccc88b7..8217d2f5383 100644 --- a/lib/spack/spack/install_test.py +++ b/lib/spack/spack/install_test.py @@ -87,6 +87,8 @@ def __init__(self, specs, alias=None): self.alias = alias self._hash = None + self.fails = 0 + @property def name(self): return self.alias if self.alias else self.content_hash @@ -135,6 +137,7 @@ def __call__(self, *args, **kwargs): shutil.rmtree(test_dir) self.write_test_result(spec, 'PASSED') except BaseException as exc: + self.fails += 1 if isinstance(exc, SyntaxError): # Create the test log file and report the error. self.ensure_stage() @@ -150,6 +153,9 @@ def __call__(self, *args, **kwargs): self.current_test_spec = None self.current_base_spec = None + if self.fails: + raise TestSuiteFailure(self.fails) + def ensure_stage(self): if not os.path.exists(self.stage): fs.mkdirp(self.stage) @@ -269,3 +275,11 @@ def __init__(self, failures): msg += '\n%s\n' % message super(TestFailure, self).__init__(msg) + + +class TestSuiteFailure(spack.error.SpackError): + """Raised when one or more tests in a suite have failed.""" + def __init__(self, num_failures): + msg = "%d test(s) in the suite failed.\n" % num_failures + + super(TestSuiteFailure, self).__init__(msg)