aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2023-08-17 20:44:42 -0400
committerEli Schwartz <eschwartz@archlinux.org>2023-08-17 21:30:32 -0400
commit1fd70a2a004900b7d97d9fc560e87d33266ecfed (patch)
tree6d4f762d8ed93370f0a228ec56db55f3e9b235ef
parent98232eb0364238958996a192d2452ea3b4f8879b (diff)
downloadmeson-1fd70a2a004900b7d97d9fc560e87d33266ecfed.zip
meson-1fd70a2a004900b7d97d9fc560e87d33266ecfed.tar.gz
meson-1fd70a2a004900b7d97d9fc560e87d33266ecfed.tar.bz2
tests: consolidate MESON_SKIP_TEST reporting and use it in unittests
Previously, we only reported the skip reason when running project tests.
-rwxr-xr-xrun_project_tests.py26
-rwxr-xr-xrun_single_test.py13
-rwxr-xr-xrun_tests.py9
-rw-r--r--unittests/baseplatformtests.py14
4 files changed, 26 insertions, 36 deletions
diff --git a/run_project_tests.py b/run_project_tests.py
index 27020ca..acfa284 100755
--- a/run_project_tests.py
+++ b/run_project_tests.py
@@ -53,10 +53,12 @@ from mesonbuild.mesonlib import MachineChoice, Popen_safe, TemporaryDirectoryWin
from mesonbuild.mlog import blue, bold, cyan, green, red, yellow, normal_green
from mesonbuild.coredata import backendlist, version as meson_version
from mesonbuild.modules.python import PythonExternalProgram
-from run_tests import get_fake_options, run_configure, get_meson_script
-from run_tests import get_backend_commands, get_backend_args_for_dir, Backend
-from run_tests import ensure_backend_detects_changes
-from run_tests import guess_backend
+from run_tests import (
+ get_fake_options, run_configure, get_meson_script, get_backend_commands,
+ get_backend_args_for_dir, Backend, ensure_backend_detects_changes,
+ guess_backend, handle_meson_skip_test,
+)
+
if T.TYPE_CHECKING:
from types import FrameType
@@ -1206,12 +1208,6 @@ class LogRunFuture:
RunFutureUnion = T.Union[TestRunFuture, LogRunFuture]
-def test_emits_skip_msg(line: str) -> bool:
- for prefix in {'Problem encountered', 'Assert failed', 'Failed to configure the CMake subproject'}:
- if f'{prefix}: MESON_SKIP_TEST' in line:
- return True
- return False
-
def _run_tests(all_tests: T.List[T.Tuple[str, T.List[TestDef], bool]],
log_name_base: str,
failfast: bool,
@@ -1324,15 +1320,7 @@ def _run_tests(all_tests: T.List[T.Tuple[str, T.List[TestDef], bool]],
skip_as_expected = True
else:
# skipped due to test outputting 'MESON_SKIP_TEST'
- for l in result.stdo.splitlines():
- if test_emits_skip_msg(l):
- is_skipped = True
- offset = l.index('MESON_SKIP_TEST') + 16
- skip_reason = l[offset:].strip()
- break
- else:
- is_skipped = False
- skip_reason = ''
+ is_skipped, skip_reason = handle_meson_skip_test(result.stdo)
if not skip_dont_care(t):
skip_as_expected = (is_skipped == t.skip_expected)
else:
diff --git a/run_single_test.py b/run_single_test.py
index eb9379a..5cd4f5e 100755
--- a/run_single_test.py
+++ b/run_single_test.py
@@ -13,7 +13,8 @@ import pathlib
import typing as T
from mesonbuild import mlog
-from run_project_tests import TestDef, load_test_json, run_test, BuildStep, test_emits_skip_msg
+from run_tests import handle_meson_skip_test
+from run_project_tests import TestDef, load_test_json, run_test, BuildStep
from run_project_tests import setup_commands, detect_system_compiler, print_tool_versions
if T.TYPE_CHECKING:
@@ -69,15 +70,7 @@ def main() -> None:
is_skipped = True
skip_reason = 'not run because preconditions were not met'
else:
- for l in result.stdo.splitlines():
- if test_emits_skip_msg(l):
- is_skipped = True
- offset = l.index('MESON_SKIP_TEST') + 16
- skip_reason = l[offset:].strip()
- break
- else:
- is_skipped = False
- skip_reason = ''
+ is_skipped, skip_reason = handle_meson_skip_test(result.stdo)
if is_skipped:
msg = mlog.yellow('SKIP:')
diff --git a/run_tests.py b/run_tests.py
index cf06337..699e293 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -187,6 +187,15 @@ if mesonlib.is_windows() or mesonlib.is_cygwin():
else:
exe_suffix = ''
+def handle_meson_skip_test(out: str) -> T.Tuple[bool, str]:
+ for line in out.splitlines():
+ for prefix in {'Problem encountered', 'Assert failed', 'Failed to configure the CMake subproject'}:
+ if f'{prefix}: MESON_SKIP_TEST' in line:
+ offset = line.index('MESON_SKIP_TEST') + 16
+ reason = line[offset:].strip()
+ return (True, reason)
+ return (False, '')
+
def get_meson_script() -> str:
'''
Guess the meson that corresponds to the `mesonbuild` that has been imported
diff --git a/unittests/baseplatformtests.py b/unittests/baseplatformtests.py
index 3008eb7..03ab1c5 100644
--- a/unittests/baseplatformtests.py
+++ b/unittests/baseplatformtests.py
@@ -41,7 +41,7 @@ import mesonbuild.modules.pkgconfig
from run_tests import (
Backend, ensure_backend_detects_changes, get_backend_commands,
get_builddir_target_args, get_meson_script, run_configure_inprocess,
- run_mtest_inprocess
+ run_mtest_inprocess, handle_meson_skip_test,
)
@@ -183,8 +183,9 @@ class BasePlatformTests(TestCase):
print('stderr:')
print(proc.stderr)
if proc.returncode != 0:
- if 'MESON_SKIP_TEST' in proc.stdout:
- raise SkipTest('Project requested skipping.')
+ skipped, reason = handle_meson_skip_test(proc.stdout)
+ if skipped:
+ raise SkipTest(f'Project requested skipping: {reason}')
raise subprocess.CalledProcessError(proc.returncode, command, output=proc.stdout)
return proc.stdout
@@ -234,8 +235,9 @@ class BasePlatformTests(TestCase):
mesonbuild.mlog._logger.log_dir = None
mesonbuild.mlog._logger.log_file = None
- if 'MESON_SKIP_TEST' in out:
- raise SkipTest('Project requested skipping.')
+ skipped, reason = handle_meson_skip_test(out)
+ if skipped:
+ raise SkipTest(f'Project requested skipping: {reason}')
if returncode != 0:
self._print_meson_log()
print('Stdout:\n')
@@ -247,8 +249,6 @@ class BasePlatformTests(TestCase):
else:
try:
out = self._run(self.setup_command + args + extra_args + build_and_src_dir_args, override_envvars=override_envvars, workdir=workdir)
- except SkipTest:
- raise SkipTest('Project requested skipping: ' + srcdir)
except Exception:
if not allow_fail:
self._print_meson_log()