File: test_options.py

package info (click to toggle)
meson-python 0.17.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,120 kB
  • sloc: python: 2,788; ansic: 219; makefile: 8
file content (37 lines) | stat: -rw-r--r-- 1,318 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# SPDX-FileCopyrightText: 2023 The meson-python developers
#
# SPDX-License-Identifier: MIT

import os
import subprocess

import pytest

import mesonpy


ninja_ver_str = subprocess.run(['ninja', '--version'], check=True, stdout=subprocess.PIPE, text=True).stdout
NINJA_VERSION = tuple(map(int, ninja_ver_str.split('.')[:3]))


# Ninja 1.9 does not support the soruce^ syntax to specify a target.
@pytest.mark.skipif(NINJA_VERSION < (1, 10), reason='Ninja version too old')
@pytest.mark.parametrize(
    ('args', 'expected'),
    [
        ([], True),
        (['-Dbuildtype=release'], True),
        (['-Dbuildtype=debug'], False),
    ],
    ids=['', '-Dbuildtype=release', '-Dbuildtype=debug'],
)
def test_ndebug(package_purelib_and_platlib, tmp_path, args, expected):
    with mesonpy._project({'setup-args': args}) as project:
        command = subprocess.run(
            # Ask ninja what is the command that would be used to
            # compile a C source file (the trailing ^ is used to
            # specify the target that is the first output of the rule
            # containing the specified source file).
            ['ninja', '-C', os.fspath(project._build_dir), '-t', 'commands', '../plat.c^'],
            stdout=subprocess.PIPE, check=True).stdout
        assert (b'-DNDEBUG' in command) == expected