Skip to content

Commit c032a80

Browse files
authored
tests: add missing test files (#1056)
Also adding back a couple of test files that I wrote but missed adding in previous PRs: * #1051 * #1047 Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
1 parent 5a8a8f4 commit c032a80

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
from scikit_build_core.builder._load_provider import process_dynamic_metadata
2+
3+
4+
def test_template_basic() -> None:
5+
pyproject = process_dynamic_metadata(
6+
{
7+
"name": "test",
8+
"version": "0.1.0",
9+
"dynamic": ["requires-python"],
10+
},
11+
{
12+
"requires-python": {
13+
"provider": "scikit_build_core.metadata.template",
14+
"result": ">={project[version]}",
15+
},
16+
},
17+
)
18+
19+
assert pyproject["requires-python"] == ">=0.1.0"
20+
21+
22+
def test_template_needs() -> None:
23+
# These are intentionally out of order to test the order of processing
24+
pyproject = process_dynamic_metadata(
25+
{
26+
"name": "test",
27+
"version": "0.1.0",
28+
"dynamic": ["requires-python", "license", "readme"],
29+
},
30+
{
31+
"license": {
32+
"provider": "scikit_build_core.metadata.template",
33+
"result": "{project[requires-python]}",
34+
},
35+
"readme": {
36+
"provider": "scikit_build_core.metadata.template",
37+
"result": {"file": "{project[license]}"},
38+
},
39+
"requires-python": {
40+
"provider": "scikit_build_core.metadata.template",
41+
"result": ">={project[version]}",
42+
},
43+
},
44+
)
45+
46+
assert pyproject["requires-python"] == ">=0.1.0"
47+
48+
49+
def test_regex() -> None:
50+
pyproject = process_dynamic_metadata(
51+
{
52+
"name": "test",
53+
"version": "0.1.0",
54+
"dynamic": ["requires-python"],
55+
},
56+
{
57+
"requires-python": {
58+
"provider": "scikit_build_core.metadata.regex",
59+
"input": "pyproject.toml",
60+
"regex": r"name = \"(?P<name>.+)\"",
61+
"result": ">={name}",
62+
},
63+
},
64+
)
65+
66+
assert pyproject["requires-python"] == ">=scikit_build_core"

tests/test_settings_docs.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from __future__ import annotations
2+
3+
from scikit_build_core.settings.documentation import DCDoc, mk_docs
4+
from scikit_build_core.settings.skbuild_docs import mk_skbuild_docs
5+
from scikit_build_core.settings.skbuild_model import ScikitBuildSettings
6+
7+
8+
def test_skbuild_docs() -> None:
9+
docs = mk_skbuild_docs()
10+
assert (
11+
"A table of defines to pass to CMake when configuring the project. Additive."
12+
in docs
13+
)
14+
assert "DEPRECATED in 0.10, use build.verbose instead." in docs
15+
assert "fail = false" in docs
16+
17+
18+
def test_mk_docs() -> None:
19+
docs = set(mk_docs(ScikitBuildSettings))
20+
21+
assert (
22+
DCDoc(
23+
name="cmake.minimum-version",
24+
default='""',
25+
docs="DEPRECATED in 0.8; use version instead.",
26+
deprecated=True,
27+
)
28+
in docs
29+
)
30+
assert (
31+
DCDoc(
32+
name="install.strip",
33+
default="true",
34+
docs="Whether to strip the binaries. True for release builds on scikit-build-core 0.5+ (0.5-0.10.5 also incorrectly set this for debug builds).",
35+
deprecated=False,
36+
)
37+
in docs
38+
)

0 commit comments

Comments
 (0)