@@ -47,6 +47,20 @@ def _write_config(root: Path, data: object, filename: str = "versions.yml") -> N
4747 path .write_text (yaml .safe_dump (data , sort_keys = False ), encoding = "utf-8" )
4848
4949
50+ def _copy_package_metadata (root : Path ) -> None :
51+ repo_root = Path (__file__ ).resolve ().parents [3 ]
52+ _write_config (root , _registry ())
53+ for relative in (
54+ "cuda_bindings/pyproject.toml" ,
55+ "cuda_bindings_12/pyproject.toml" ,
56+ "cuda_bindings_12/pixi.toml" ,
57+ "cuda_python/setup.py" ,
58+ ):
59+ destination = root / relative
60+ destination .parent .mkdir (parents = True , exist_ok = True )
61+ shutil .copyfile (repo_root / relative , destination )
62+
63+
5064@pytest .mark .parametrize (
5165 ("tag" , "package_root" , "version" ),
5266 (
@@ -144,24 +158,20 @@ def test_config_loader_reports_invalid_yaml(tmp_path):
144158 '[tool.setuptools_scm]\n tag_regex = "custom"' ,
145159 "must use setuptools-scm's default tag parser" ,
146160 ),
161+ (
162+ "cuda_bindings/pyproject.toml" ,
163+ "[tool.setuptools_scm]" ,
164+ '[tool.setuptools_scm]\n fallback_version = "13.4.0.dev0"' ,
165+ "current bindings root must not declare fallback_version" ,
166+ ),
147167 ("cuda_python/setup.py" , "v13.4.*" , "v13.5.*" , "SCM_DESCRIBE_MATCH_BY_MAJOR must match" ),
148168 ("cuda_python/setup.py" , "12.9.10.dev0" , "12.9.9.dev0" , "MAINTENANCE_FALLBACK_VERSION must match" ),
149169 ("cuda_bindings_12/pixi.toml" , "12.9.10.dev0" , "12.9.9.dev0" , "package.version must match" ),
150170 ),
151171)
152- @pytest .mark .agent_authored (model = "gpt-6-astra " )
172+ @pytest .mark .agent_authored (model = "gpt-6" )
153173def test_metadata_check_rejects_independent_package_drift (tmp_path , capsys , path , before , after , message ):
154- repo_root = Path (__file__ ).resolve ().parents [3 ]
155- _write_config (tmp_path , _registry ())
156- for relative in (
157- "cuda_bindings/pyproject.toml" ,
158- "cuda_bindings_12/pyproject.toml" ,
159- "cuda_bindings_12/pixi.toml" ,
160- "cuda_python/setup.py" ,
161- ):
162- destination = tmp_path / relative
163- destination .parent .mkdir (parents = True , exist_ok = True )
164- shutil .copyfile (repo_root / relative , destination )
174+ _copy_package_metadata (tmp_path )
165175 changed = tmp_path / path
166176 content = changed .read_text (encoding = "utf-8" )
167177 assert before in content
@@ -173,6 +183,31 @@ def test_metadata_check_rejects_independent_package_drift(tmp_path, capsys, path
173183 assert message in capsys .readouterr ().err
174184
175185
186+ @pytest .mark .parametrize (
187+ ("package_root" , "role" , "before" , "after" ),
188+ (
189+ ("cuda_bindings_12" , "maintenance" , "v12.9.[1-9]*" , "v12.9.*" ),
190+ ("cuda_bindings" , "current" , "v13.4.*" , "v13.4.[1-9]*" ),
191+ ),
192+ )
193+ @pytest .mark .agent_authored (model = "gpt-6" )
194+ def test_metadata_check_rejects_selectors_changed_together (tmp_path , capsys , package_root , role , before , after ):
195+ _copy_package_metadata (tmp_path )
196+ args = ["--config" , str (tmp_path / "ci" / "versions.yml" ), "--check-package-metadata" ]
197+ assert main (args ) == 0
198+
199+ for relative in (f"{ package_root } /pyproject.toml" , "cuda_python/setup.py" ):
200+ changed = tmp_path / relative
201+ content = changed .read_text (encoding = "utf-8" )
202+ assert before in content
203+ changed .write_text (content .replace (before , after ), encoding = "utf-8" )
204+
205+ with pytest .raises (SystemExit , match = "2" ):
206+ main (args )
207+
208+ assert f"using { before !r} for the { role } root" in capsys .readouterr ().err
209+
210+
176211@pytest .mark .agent_authored (model = "gpt-6-sol" )
177212def test_cli_writes_selected_package_to_github_env (tmp_path , capsys , monkeypatch ):
178213 output = tmp_path / "github-env"
0 commit comments