diff --git a/VERSION b/VERSION index a8eec69..a9ad2ac 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.179 +0.5.181 diff --git a/tests/test_version_parity.py b/tests/test_version_parity.py new file mode 100644 index 0000000..c2f6fb4 --- /dev/null +++ b/tests/test_version_parity.py @@ -0,0 +1,38 @@ +"""Test to strictly enforce version parity across all carriers and package code.""" + +from __future__ import annotations + +import re +from pathlib import Path + +import code2llm + + +def test_package_version_is_valid_semver(): + """__version__ must be a valid semver string and not 'unknown'.""" + assert code2llm.__version__ != "unknown" + assert re.match(r"^\d+\.\d+\.\d+", code2llm.__version__), f"Invalid version format: {code2llm.__version__}" + + +def test_version_carrier_parity(): + """VERSION file, pyproject.toml, and code2llm.__version__ must match strictly.""" + root = Path(__file__).resolve().parent.parent + version_file = root / "VERSION" + assert version_file.is_file(), "VERSION file is missing" + expected_version = version_file.read_text(encoding="utf-8").strip() + + # 1. Check code2llm.__version__ + assert code2llm.__version__ == expected_version, ( + f"code2llm.__version__ ({code2llm.__version__}) does not match VERSION ({expected_version})" + ) + + # 2. Check pyproject.toml + pyproject_file = root / "pyproject.toml" + assert pyproject_file.is_file(), "pyproject.toml is missing" + pyproject_text = pyproject_file.read_text(encoding="utf-8") + match = re.search(r'(?m)^version\s*=\s*["\']([^"\']+)["\']', pyproject_text) + assert match, "version not declared in pyproject.toml" + pyproject_version = match.group(1) + assert pyproject_version == expected_version, ( + f"pyproject.toml version ({pyproject_version}) does not match VERSION ({expected_version})" + )