File: test_name_main.py

package info (click to toggle)
scikit-build-core 0.11.1-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,408 kB
  • sloc: python: 13,380; ansic: 140; cpp: 134; sh: 27; fortran: 18; makefile: 7
file content (68 lines) | stat: -rw-r--r-- 1,874 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import os
import subprocess
import sys
from pathlib import Path

DIR = Path(__file__).parent.resolve()


def test_cattrs_converter():
    env = os.environ.copy()
    if "FORCE_COLOR" in env:
        del env["FORCE_COLOR"]
    out = subprocess.run(
        [
            sys.executable,
            "-m",
            "scikit_build_core.file_api._cattrs_converter",
            str(DIR / "api/simple_pure/.cmake/api/v1/reply"),
        ],
        check=True,
        env=env,
        stdout=subprocess.PIPE,
        text=True,
    )
    assert "version=CMakeVersion" in out.stdout
    assert "toolchains_v1=Toolchains(" in out.stdout


def test_query(tmp_path):
    env = os.environ.copy()
    if "FORCE_COLOR" in env:
        del env["FORCE_COLOR"]
    build_dir = tmp_path / "test_query"
    build_dir.mkdir()
    out = subprocess.run(
        [sys.executable, "-m", "scikit_build_core.file_api.query", str(build_dir)],
        check=True,
        env=env,
        stdout=subprocess.PIPE,
        text=True,
    )
    api_dir = build_dir / ".cmake/api/v1"
    query_dir = api_dir / "query"
    assert query_dir.joinpath("codemodel-v2").is_file()
    assert query_dir.joinpath("cache-v2").is_file()
    assert query_dir.joinpath("cmakeFiles-v1").is_file()
    assert query_dir.joinpath("toolchains-v1").is_file()
    assert str(api_dir / "reply") == out.stdout.strip()


def test_reply():
    env = os.environ.copy()
    if "FORCE_COLOR" in env:
        del env["FORCE_COLOR"]
    out = subprocess.run(
        [
            sys.executable,
            "-m",
            "scikit_build_core.file_api.reply",
            str(DIR / "api/simple_pure/.cmake/api/v1/reply"),
        ],
        check=True,
        env=env,
        stdout=subprocess.PIPE,
        text=True,
    )
    assert "version=CMakeVersion" in out.stdout
    assert "toolchains_v1=Toolchains(" in out.stdout