Skip to content

Commit 3ca4d3c

Browse files
committed
TST: enable fatal meson warnings for almost all test packages
This uses a pytest ``autouse`` fixture to monkeypatch the function that validates the ``pyproject.toml`` meson-python configuration to add ``--fatal-meson-warnings`` to the ``meson setup`` arguments, unless ``--no-fatal-meson-warnings`` is specified by the package.
1 parent 1cfeab1 commit 3ca4d3c

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

tests/conftest.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,33 @@ def cleanenv():
192192
# $MACOSX_DEPLOYMENT_TARGET affects the computation of the platform tag on macOS.
193193
yield mpatch.delenv('MACOSX_DEPLOYMENT_TARGET', raising=False)
194194
mpatch.undo()
195+
196+
197+
@pytest.fixture(autouse=True, scope='session')
198+
def meson_fatal_warnings():
199+
# Cannot use the 'monkeypatch' fixture because of scope mismatch.
200+
mpatch = pytest.MonkeyPatch()
201+
mesonpy_project_init = mesonpy.Project.__init__
202+
203+
def __init__(self, source_dir, build_dir, meson_args=None, editable_verbose=False):
204+
if pathlib.Path(source_dir).absolute().name not in {
205+
206+
# The CMake subproject emits ``WARNING: CMake Toolchain:
207+
# Failed to determine CMake compilers state`` on some
208+
# systems. This is probably related to missing Rust or ObjC
209+
# toolchains.
210+
'cmake-subproject',
211+
212+
# The ``link-against-local-lib`` package uses linker arguments
213+
# to add RPATH entries. This functionality is deprecated in
214+
# Meson but it is used in the wild thus we should make sure it
215+
# keeps working.
216+
'link-against-local-lib',
217+
218+
}:
219+
if meson_args is None:
220+
meson_args = {}
221+
meson_args.setdefault('setup', []).append('--fatal-meson-warnings')
222+
mesonpy_project_init(self, source_dir, build_dir, meson_args, editable_verbose)
223+
224+
mpatch.setattr(mesonpy.Project, '__init__', __init__)

tests/packages/link-against-local-lib/pyproject.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,3 @@ requires = ['meson-python']
88

99
[tool.meson-python]
1010
allow-windows-internal-shared-libs = true
11-
12-
[tool.meson-python.args]
13-
setup = ['--no-fatal-meson-warnings']

tests/test_project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ def test_ios_project(package_simple, monkeypatch, multiarch, tmp_path):
399399
project = mesonpy.Project(source_dir=package_simple, build_dir=tmp_path)
400400

401401
# Meson configuration points at the cross file
402-
assert project._meson_args['setup'] == ['--cross-file', os.fspath(tmp_path / 'meson-python-cross-file.ini')]
402+
assert project._meson_args['setup'][-2:] == ['--cross-file', os.fspath(tmp_path / 'meson-python-cross-file.ini')]
403403

404404
# Meson config files exist, and have some relevant keys
405405
assert (tmp_path / 'meson-python-native-file.ini').exists()

0 commit comments

Comments
 (0)