Skip to content

Commit c3d8702

Browse files
committed
Add an initial equivalence test for build-details.json
Signed-off-by: Michał Górny <mgorny@gentoo.org>
1 parent 8509bf3 commit c3d8702

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_tags.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# SPDX-License-Identifier: MIT
44

55
import importlib.machinery
6+
import json
67
import os
78
import pathlib
89
import platform
@@ -36,8 +37,18 @@ def get_abi3_suffix():
3637
return suffix
3738

3839

40+
def get_build_details_json():
41+
# Technically, this is only applicable to 3.14+, but we account for FileNotFoundError anyway.
42+
try:
43+
with open(pathlib.Path(sysconfig.get_path('stdlib')) / 'build-details.json') as f:
44+
return json.load(f)
45+
except FileNotFoundError:
46+
return None
47+
48+
3949
SUFFIX = sysconfig.get_config_var('EXT_SUFFIX')
4050
ABI3SUFFIX = get_abi3_suffix()
51+
BUILD_DETAILS_JSON = get_build_details_json()
4152

4253

4354
def test_wheel_tag():
@@ -141,3 +152,8 @@ def test_tag_mixed_abi():
141152
}, pure=False, limited_api=True)
142153
with pytest.raises(mesonpy.BuildError, match='The package declares compatibility with Python limited API but '):
143154
assert str(builder.tag) == f'{INTERPRETER}-abi3-{PLATFORM}'
155+
156+
157+
@pytest.mark.skipif(BUILD_DETAILS_JSON is None, reason='No build-details.json for this interpreter')
158+
def test_system_build_details():
159+
assert str(mesonpy._tags.Tag()) == str(mesonpy._tags.Tag(build_details=BUILD_DETAILS_JSON))

0 commit comments

Comments
 (0)