Skip to content

Commit

Permalink
Tests of config parsing when hatch is involved
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Nov 4, 2023
1 parent 065efe3 commit 9456ebd
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/data/config-error/other-hatch.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = ["hatchling", "versioningit"]
build-backend = "hatchling.build"

[tool.hatch.version]
source = "not-versioningit"
1 change: 1 addition & 0 deletions test/data/config-error/other-hatch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
versioningit not enabled in pyproject.toml
31 changes: 31 additions & 0 deletions test/data/config/hatch-and-std.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from versioningit.config import Config, ConfigSection
from versioningit.methods import EntryPointSpec

cfg = Config(
vcs=ConfigSection(
method_spec=EntryPointSpec(group="versioningit.vcs", name="git"),
params={},
),
tag2version=ConfigSection(
method_spec=EntryPointSpec(group="versioningit.tag2version", name="basic"),
params={},
),
next_version=ConfigSection(
method_spec=EntryPointSpec(group="versioningit.next_version", name="minor"),
params={},
),
format=ConfigSection(
method_spec=EntryPointSpec(group="versioningit.format", name="basic"),
params={
"distance": "{next_version}.dev{distance}+{vcs}{rev}",
"dirty": "{version}+dirty",
"distance-dirty": "{next_version}.dev{distance}+{vcs}{rev}.dirty",
},
),
template_fields=ConfigSection(
method_spec=EntryPointSpec(group="versioningit.template_fields", name="basic"),
params={},
),
write=None,
onbuild=None,
)
12 changes: 12 additions & 0 deletions test/data/config/hatch-and-std.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[tool.hatch.version]
source = "versioningit"

[tool.hatch.version.format]
distance = "{next_version}.dev{distance}+{vcs}{rev}"
dirty = "{version}+dirty"
distance-dirty = "{next_version}.dev{distance}+{vcs}{rev}.dirty"

[tool.versioningit.format]
distance = "{next_version}~{vcs}{rev}"
dirty = "{version}~dirty"
distance-dirty = "{next_version}~{vcs}{rev}.dirty"
31 changes: 31 additions & 0 deletions test/data/config/hatch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from versioningit.config import Config, ConfigSection
from versioningit.methods import EntryPointSpec

cfg = Config(
vcs=ConfigSection(
method_spec=EntryPointSpec(group="versioningit.vcs", name="git"),
params={},
),
tag2version=ConfigSection(
method_spec=EntryPointSpec(group="versioningit.tag2version", name="basic"),
params={},
),
next_version=ConfigSection(
method_spec=EntryPointSpec(group="versioningit.next_version", name="minor"),
params={},
),
format=ConfigSection(
method_spec=EntryPointSpec(group="versioningit.format", name="basic"),
params={
"distance": "{next_version}.dev{distance}+{vcs}{rev}",
"dirty": "{version}+dirty",
"distance-dirty": "{next_version}.dev{distance}+{vcs}{rev}.dirty",
},
),
template_fields=ConfigSection(
method_spec=EntryPointSpec(group="versioningit.template_fields", name="basic"),
params={},
),
write=None,
onbuild=None,
)
7 changes: 7 additions & 0 deletions test/data/config/hatch.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[tool.hatch.version]
source = "versioningit"

[tool.hatch.version.format]
distance = "{next_version}.dev{distance}+{vcs}{rev}"
dirty = "{version}+dirty"
distance-dirty = "{next_version}.dev{distance}+{vcs}{rev}.dirty"
31 changes: 31 additions & 0 deletions test/data/config/other-hatch-and-std.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from versioningit.config import Config, ConfigSection
from versioningit.methods import EntryPointSpec

cfg = Config(
vcs=ConfigSection(
method_spec=EntryPointSpec(group="versioningit.vcs", name="git"),
params={},
),
tag2version=ConfigSection(
method_spec=EntryPointSpec(group="versioningit.tag2version", name="basic"),
params={},
),
next_version=ConfigSection(
method_spec=EntryPointSpec(group="versioningit.next_version", name="minor"),
params={},
),
format=ConfigSection(
method_spec=EntryPointSpec(group="versioningit.format", name="basic"),
params={
"distance": "{next_version}~{vcs}{rev}",
"dirty": "{version}~dirty",
"distance-dirty": "{next_version}~{vcs}{rev}.dirty",
},
),
template_fields=ConfigSection(
method_spec=EntryPointSpec(group="versioningit.template_fields", name="basic"),
params={},
),
write=None,
onbuild=None,
)
12 changes: 12 additions & 0 deletions test/data/config/other-hatch-and-std.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[tool.hatch.version]
source = "not-versioningit"

[tool.hatch.version.format]
distance = "{next_version}.dev{distance}+{vcs}{rev}"
dirty = "{version}+dirty"
distance-dirty = "{next_version}.dev{distance}+{vcs}{rev}.dirty"

[tool.versioningit.format]
distance = "{next_version}~{vcs}{rev}"
dirty = "{version}~dirty"
distance-dirty = "{next_version}~{vcs}{rev}.dirty"

0 comments on commit 9456ebd

Please sign in to comment.