diff options
author | Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com> | 2021-09-15 05:04:59 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-15 08:04:59 -0400 |
commit | f0b4afe7db15d8cd2dbd8a77c29dcaf8f7ddb5e4 (patch) | |
tree | 917bd871afedc82f23661c6ee586ae1069d57e46 /lib | |
parent | 75497537a44de37f65b6a321b83e0167c854be09 (diff) | |
download | spack-f0b4afe7db15d8cd2dbd8a77c29dcaf8f7ddb5e4.tar.gz spack-f0b4afe7db15d8cd2dbd8a77c29dcaf8f7ddb5e4.tar.bz2 spack-f0b4afe7db15d8cd2dbd8a77c29dcaf8f7ddb5e4.tar.xz spack-f0b4afe7db15d8cd2dbd8a77c29dcaf8f7ddb5e4.zip |
Raise exception when 1+ stand-alone tests fail (#25857)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/install_test.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/spack/spack/install_test.py b/lib/spack/spack/install_test.py index dbc1ccc88b..8217d2f538 100644 --- a/lib/spack/spack/install_test.py +++ b/lib/spack/spack/install_test.py @@ -87,6 +87,8 @@ class TestSuite(object): 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 @@ class TestSuite(object): 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 @@ class TestSuite(object): 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 @@ class TestFailure(spack.error.SpackError): 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) |