summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xrun_project_tests.py5
-rwxr-xr-xrun_single_test.py2
-rwxr-xr-xrun_tests.py14
-rwxr-xr-xrun_unittests.py2
4 files changed, 17 insertions, 6 deletions
diff --git a/run_project_tests.py b/run_project_tests.py
index 9665f3e38..2e9992a40 100755
--- a/run_project_tests.py
+++ b/run_project_tests.py
@@ -233,6 +233,9 @@ class TestDef:
self.do_not_set_opts = [] # type: T.List[str]
self.stdout = [] # type: T.List[T.Dict[str, str]]
+ # Always print a stack trace for Meson exceptions
+ self.env['MESON_FORCE_BACKTRACE'] = '1'
+
def __repr__(self) -> str:
return '<{}: {:<48} [{}: {}] -- {}>'.format(type(self).__name__, str(self.path), self.name, self.args, self.skip)
@@ -619,7 +622,7 @@ def _run_test(test: TestDef,
gen_args.extend(['--native-file', nativefile.as_posix()])
if crossfile.exists():
gen_args.extend(['--cross-file', crossfile.as_posix()])
- (returncode, stdo, stde) = run_configure(gen_args, env=test.env)
+ (returncode, stdo, stde) = run_configure(gen_args, env=test.env, catch_exception=True)
try:
logfile = Path(test_build_dir, 'meson-logs', 'meson-log.txt')
mesonlog = logfile.open(errors='ignore', encoding='utf-8').read()
diff --git a/run_single_test.py b/run_single_test.py
index 703f0a680..4d705078d 100755
--- a/run_single_test.py
+++ b/run_single_test.py
@@ -57,7 +57,7 @@ def main() -> None:
failed = True
else:
msg = mlog.green('PASS:')
- mlog.log(msg, test.display_name())
+ mlog.log(msg, *test.display_name())
if result is not None and result.msg and 'MESON_SKIP_TEST' not in result.stdo:
mlog.log('reason:', result.msg)
if result.step is BuildStep.configure:
diff --git a/run_tests.py b/run_tests.py
index 80ea38f76..656007b16 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -22,6 +22,7 @@ import subprocess
import tempfile
import platform
import argparse
+import traceback
from io import StringIO
from enum import Enum
from glob import glob
@@ -268,12 +269,19 @@ def clear_meson_configure_class_caches() -> None:
dependencies.PkgConfigDependency.pkgbin_cache = {}
dependencies.PkgConfigDependency.class_pkgbin = mesonlib.PerMachine(None, None)
-def run_configure_inprocess(commandlist: T.List[str], env: T.Optional[T.Dict[str, str]] = None) -> T.Tuple[int, str, str]:
+def run_configure_inprocess(commandlist: T.List[str], env: T.Optional[T.Dict[str, str]] = None, catch_exception: bool = False) -> T.Tuple[int, str, str]:
stderr = StringIO()
stdout = StringIO()
+ returncode = 0
with mock.patch.dict(os.environ, env or {}), mock.patch.object(sys, 'stdout', stdout), mock.patch.object(sys, 'stderr', stderr):
try:
returncode = mesonmain.run(commandlist, get_meson_script())
+ except Exception:
+ if catch_exception:
+ returncode = 1
+ traceback.print_exc()
+ else:
+ raise
finally:
clear_meson_configure_class_caches()
return returncode, stdout.getvalue(), stderr.getvalue()
@@ -282,11 +290,11 @@ def run_configure_external(full_command: T.List[str], env: T.Optional[T.Dict[str
pc, o, e = mesonlib.Popen_safe(full_command, env=env)
return pc.returncode, o, e
-def run_configure(commandlist: T.List[str], env: T.Optional[T.Dict[str, str]] = None) -> T.Tuple[int, str, str]:
+def run_configure(commandlist: T.List[str], env: T.Optional[T.Dict[str, str]] = None, catch_exception: bool = False) -> T.Tuple[int, str, str]:
global meson_exe
if meson_exe:
return run_configure_external(meson_exe + commandlist, env=env)
- return run_configure_inprocess(commandlist, env=env)
+ return run_configure_inprocess(commandlist, env=env, catch_exception=catch_exception)
def print_system_info():
print(mlog.bold('System information.'))
diff --git a/run_unittests.py b/run_unittests.py
index 8c20e723f..f81462fb0 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -6165,7 +6165,7 @@ class FailureTests(BasePlatformTests):
'''
tdir = os.path.join(self.unit_test_dir, '21 exit status')
with self.assertRaises(subprocess.CalledProcessError) as cm:
- self.init(tdir, inprocess=False, override_envvars = {'MESON_UNIT_TEST': '1'})
+ self.init(tdir, inprocess=False, override_envvars = {'MESON_UNIT_TEST': '1', 'MESON_FORCE_BACKTRACE': ''})
self.assertEqual(cm.exception.returncode, 2)
self.wipe()