diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2021-07-28 11:15:31 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2021-08-16 16:21:51 -0700 |
commit | 310d7d13f4566bc8aac56b87c54594e5e442528f (patch) | |
tree | 174c022ce14f49d8ea4633015f989cc90f138cda /unittests/baseplatformtests.py | |
parent | 7daed5faf8a7a0543c45c90a2e07b568a30a9ecf (diff) | |
download | meson-310d7d13f4566bc8aac56b87c54594e5e442528f.zip meson-310d7d13f4566bc8aac56b87c54594e5e442528f.tar.gz meson-310d7d13f4566bc8aac56b87c54594e5e442528f.tar.bz2 |
unittests/base: Move code out of the try block of a try/except statement
There are two problems with having this in the try/except block. The
first is that both of the if statements will raise, and the except
statement cathces `Exception`, so it catches these two cases, prints a
message that we either don't want or already printed, then re-raises.
Diffstat (limited to 'unittests/baseplatformtests.py')
-rw-r--r-- | unittests/baseplatformtests.py | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/unittests/baseplatformtests.py b/unittests/baseplatformtests.py index e347303..375698d 100644 --- a/unittests/baseplatformtests.py +++ b/unittests/baseplatformtests.py @@ -12,13 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -import subprocess -import re +from pathlib import PurePath +from unittest import mock, TestCase, SkipTest import json -import tempfile import os -from unittest import mock, TestCase, SkipTest -from pathlib import PurePath +import re +import subprocess +import sys +import tempfile +import typing as T import mesonbuild.mlog import mesonbuild.depfile @@ -176,16 +178,7 @@ class BasePlatformTests(TestCase): self.privatedir = os.path.join(self.builddir, 'meson-private') if inprocess: try: - (returncode, out, err) = run_configure_inprocess(self.meson_args + args + extra_args, override_envvars) - if 'MESON_SKIP_TEST' in out: - raise SkipTest('Project requested skipping.') - if returncode != 0: - self._print_meson_log() - print('Stdout:\n') - print(out) - print('Stderr:\n') - print(err) - raise RuntimeError('Configure failed') + returncode, out, err = run_configure_inprocess(self.meson_args + args + extra_args, override_envvars) except Exception as e: # Don't double print if str(e) != 'Configure failed': @@ -196,6 +189,16 @@ class BasePlatformTests(TestCase): mesonbuild.mlog.shutdown() mesonbuild.mlog.log_dir = None mesonbuild.mlog.log_file = None + + if 'MESON_SKIP_TEST' in out: + raise SkipTest('Project requested skipping.') + if returncode != 0: + self._print_meson_log() + print('Stdout:\n') + print(out) + print('Stderr:\n') + print(err) + raise RuntimeError('Configure failed') else: try: out = self._run(self.setup_command + args + extra_args, override_envvars=override_envvars, workdir=workdir) |