tests: Always enable the traceback in run_project_tests.py

pull/8903/head
Daniel Mensinger 3 years ago
parent 10afec575b
commit b2112bc4f6
  1. 5
      run_project_tests.py
  2. 2
      run_single_test.py
  3. 14
      run_tests.py
  4. 2
      run_unittests.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()

@ -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:

@ -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.'))

@ -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()

Loading…
Cancel
Save