From 9456ebdfb26df3b74ca5be3616beae130889fc64 Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Sat, 4 Nov 2023 09:29:29 -0400 Subject: [PATCH] Tests of config parsing when hatch is involved --- test/data/config-error/other-hatch.toml | 6 +++++ test/data/config-error/other-hatch.txt | 1 + test/data/config/hatch-and-std.py | 31 +++++++++++++++++++++++ test/data/config/hatch-and-std.toml | 12 +++++++++ test/data/config/hatch.py | 31 +++++++++++++++++++++++ test/data/config/hatch.toml | 7 +++++ test/data/config/other-hatch-and-std.py | 31 +++++++++++++++++++++++ test/data/config/other-hatch-and-std.toml | 12 +++++++++ 8 files changed, 131 insertions(+) create mode 100644 test/data/config-error/other-hatch.toml create mode 100644 test/data/config-error/other-hatch.txt create mode 100644 test/data/config/hatch-and-std.py create mode 100644 test/data/config/hatch-and-std.toml create mode 100644 test/data/config/hatch.py create mode 100644 test/data/config/hatch.toml create mode 100644 test/data/config/other-hatch-and-std.py create mode 100644 test/data/config/other-hatch-and-std.toml diff --git a/test/data/config-error/other-hatch.toml b/test/data/config-error/other-hatch.toml new file mode 100644 index 0000000..4c0a29b --- /dev/null +++ b/test/data/config-error/other-hatch.toml @@ -0,0 +1,6 @@ +[build-system] +requires = ["hatchling", "versioningit"] +build-backend = "hatchling.build" + +[tool.hatch.version] +source = "not-versioningit" diff --git a/test/data/config-error/other-hatch.txt b/test/data/config-error/other-hatch.txt new file mode 100644 index 0000000..2116075 --- /dev/null +++ b/test/data/config-error/other-hatch.txt @@ -0,0 +1 @@ +versioningit not enabled in pyproject.toml diff --git a/test/data/config/hatch-and-std.py b/test/data/config/hatch-and-std.py new file mode 100644 index 0000000..b153f61 --- /dev/null +++ b/test/data/config/hatch-and-std.py @@ -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, +) diff --git a/test/data/config/hatch-and-std.toml b/test/data/config/hatch-and-std.toml new file mode 100644 index 0000000..31a8e5f --- /dev/null +++ b/test/data/config/hatch-and-std.toml @@ -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" diff --git a/test/data/config/hatch.py b/test/data/config/hatch.py new file mode 100644 index 0000000..b153f61 --- /dev/null +++ b/test/data/config/hatch.py @@ -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, +) diff --git a/test/data/config/hatch.toml b/test/data/config/hatch.toml new file mode 100644 index 0000000..3e73f3b --- /dev/null +++ b/test/data/config/hatch.toml @@ -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" diff --git a/test/data/config/other-hatch-and-std.py b/test/data/config/other-hatch-and-std.py new file mode 100644 index 0000000..0f9272b --- /dev/null +++ b/test/data/config/other-hatch-and-std.py @@ -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, +) diff --git a/test/data/config/other-hatch-and-std.toml b/test/data/config/other-hatch-and-std.toml new file mode 100644 index 0000000..aff96bb --- /dev/null +++ b/test/data/config/other-hatch-and-std.toml @@ -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"