Skip to content

Commit 4ded0a3

Browse files
committed
TST: add test to check default options
1 parent 1526403 commit 4ded0a3

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

tests/test_options.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,23 @@ def test_ndebug(package_purelib_and_platlib, tmp_path, args, expected):
3535
['ninja', '-C', os.fspath(project._build_dir), '-t', 'commands', '../plat.c^'],
3636
stdout=subprocess.PIPE, check=True).stdout
3737
assert (b'-DNDEBUG' in command) == expected
38+
39+
40+
def test_default_options(package_purelib_and_platlib, tmp_path, mocker):
41+
meson = mocker.spy(mesonpy.Project, '_run')
42+
43+
project = mesonpy.Project(package_purelib_and_platlib, tmp_path)
44+
45+
mesonpy_default_options = {'-Dbuildtype=release', '-Db_ndebug=if-release', '-Db_vscrt=md'}
46+
# Check if default options were passed
47+
assert mesonpy_default_options.issubset(meson.call_args_list[0][0][1])
48+
49+
options = {opt['name']: opt['value'] for opt in project._info('intro-buildoptions')}
50+
51+
# Check if default options have taken effect
52+
assert options['buildtype'] == 'release'
53+
assert options['b_ndebug'] == 'if-release'
54+
55+
compilers = project._info('intro-compilers')
56+
if compilers['build']['c']['id'] in {'msvc', 'clang-cl', 'intel-cl'}:
57+
assert options['b_vscrt'] == 'md'

0 commit comments

Comments
 (0)