| 
4 | 4 | import shutil  | 
5 | 5 | import sysconfig  | 
6 | 6 | from pathlib import Path  | 
 | 7 | +from textwrap import dedent  | 
7 | 8 | from typing import TYPE_CHECKING  | 
8 | 9 | 
 
  | 
9 | 10 | import pytest  | 
10 | 11 | from packaging.specifiers import SpecifierSet  | 
11 | 12 | from packaging.version import Version  | 
12 | 13 | 
 
  | 
 | 14 | +from scikit_build_core.builder.builder import Builder  | 
13 | 15 | from scikit_build_core.cmake import CMake, CMaker  | 
14 | 16 | from scikit_build_core.errors import CMakeNotFoundError  | 
 | 17 | +from scikit_build_core.settings.skbuild_read_settings import SettingsReader  | 
15 | 18 | 
 
  | 
16 | 19 | if TYPE_CHECKING:  | 
17 | 20 |     from collections.abc import Generator  | 
@@ -201,6 +204,41 @@ def test_cmake_paths(  | 
201 | 204 |     assert len(fp.calls) == 2  | 
202 | 205 | 
 
  | 
203 | 206 | 
 
  | 
 | 207 | +@pytest.mark.configure  | 
 | 208 | +def test_cmake_defines(  | 
 | 209 | +    tmp_path: Path,  | 
 | 210 | +):  | 
 | 211 | +    source_dir = DIR / "packages" / "cmake_defines"  | 
 | 212 | +    binary_dir = tmp_path / "build"  | 
 | 213 | + | 
 | 214 | +    config = CMaker(  | 
 | 215 | +        CMake.default_search(),  | 
 | 216 | +        source_dir=source_dir,  | 
 | 217 | +        build_dir=binary_dir,  | 
 | 218 | +        build_type="Release",  | 
 | 219 | +    )  | 
 | 220 | + | 
 | 221 | +    reader = SettingsReader.from_file(source_dir / "pyproject.toml")  | 
 | 222 | + | 
 | 223 | +    builder = Builder(reader.settings, config)  | 
 | 224 | +    builder.configure(defines={})  | 
 | 225 | + | 
 | 226 | +    configure_log = Path.read_text(binary_dir / "log.txt")  | 
 | 227 | +    assert configure_log == dedent(  | 
 | 228 | +        """\  | 
 | 229 | +        ONE_LEVEL_LIST.LENGTH = 4  | 
 | 230 | +        Foo  | 
 | 231 | +        Bar  | 
 | 232 | +        ExceptionallyLargeListEntryThatWouldOverflowTheLine  | 
 | 233 | +        Baz  | 
 | 234 | +        NESTED_LIST.LENGTH = 3  | 
 | 235 | +        Apple  | 
 | 236 | +        Lemon;Lime  | 
 | 237 | +        Banana  | 
 | 238 | +        """  | 
 | 239 | +    )  | 
 | 240 | + | 
 | 241 | + | 
204 | 242 | def test_get_cmake_via_envvar(monkeypatch: pytest.MonkeyPatch, fp):  | 
205 | 243 |     monkeypatch.setattr("shutil.which", lambda x: x)  | 
206 | 244 |     cmake_path = Path("some-prog")  | 
 | 
0 commit comments