|
2 | 2 |
|
3 | 3 | import json |
4 | 4 | import os |
| 5 | +import warnings |
5 | 6 |
|
| 7 | +import pytest |
6 | 8 | import yaml |
7 | 9 |
|
8 | 10 | from specify_cli.integrations import get_integration |
@@ -34,6 +36,31 @@ def test_setup_creates_agent_md_files(self, tmp_path): |
34 | 36 | assert f.parent == tmp_path / ".github" / "agents" |
35 | 37 | assert f.name.endswith(".agent.md") |
36 | 38 |
|
| 39 | + def test_setup_warns_legacy_markdown_default_is_deprecated(self, tmp_path): |
| 40 | + from specify_cli.integrations.copilot import CopilotIntegration |
| 41 | + copilot = CopilotIntegration() |
| 42 | + m = IntegrationManifest("copilot", tmp_path) |
| 43 | + |
| 44 | + with pytest.warns(UserWarning, match="Copilot legacy markdown mode is deprecated"): |
| 45 | + created = copilot.setup(tmp_path, m) |
| 46 | + |
| 47 | + assert any(f.name.endswith(".agent.md") for f in created) |
| 48 | + |
| 49 | + def test_skills_setup_does_not_warn_about_legacy_default(self, tmp_path): |
| 50 | + from specify_cli.integrations.copilot import CopilotIntegration |
| 51 | + copilot = CopilotIntegration() |
| 52 | + m = IntegrationManifest("copilot", tmp_path) |
| 53 | + |
| 54 | + with warnings.catch_warnings(record=True) as caught: |
| 55 | + warnings.simplefilter("always") |
| 56 | + created = copilot.setup(tmp_path, m, parsed_options={"skills": True}) |
| 57 | + |
| 58 | + assert not any( |
| 59 | + "Copilot legacy markdown mode is deprecated" in str(item.message) |
| 60 | + for item in caught |
| 61 | + ) |
| 62 | + assert any(f.name == "SKILL.md" for f in created) |
| 63 | + |
37 | 64 | def test_setup_creates_companion_prompts(self, tmp_path): |
38 | 65 | from specify_cli.integrations.copilot import CopilotIntegration |
39 | 66 | copilot = CopilotIntegration() |
@@ -295,6 +322,51 @@ def test_complete_file_inventory_ps(self, tmp_path): |
295 | 322 | f"Extra: {sorted(set(actual) - set(expected))}" |
296 | 323 | ) |
297 | 324 |
|
| 325 | + def test_default_cli_init_warns_legacy_markdown_is_deprecated(self, tmp_path): |
| 326 | + """Default Copilot init should warn users about the future skills default.""" |
| 327 | + from typer.testing import CliRunner |
| 328 | + from specify_cli import app |
| 329 | + project = tmp_path / "default-warning" |
| 330 | + project.mkdir() |
| 331 | + old_cwd = os.getcwd() |
| 332 | + try: |
| 333 | + os.chdir(project) |
| 334 | + with pytest.warns( |
| 335 | + UserWarning, |
| 336 | + match="Copilot legacy markdown mode is deprecated", |
| 337 | + ): |
| 338 | + result = CliRunner().invoke(app, [ |
| 339 | + "init", "--here", "--integration", "copilot", "--script", "sh", |
| 340 | + ], catch_exceptions=False) |
| 341 | + finally: |
| 342 | + os.chdir(old_cwd) |
| 343 | + |
| 344 | + assert result.exit_code == 0, result.output |
| 345 | + |
| 346 | + def test_skills_cli_init_does_not_warn_about_legacy_markdown(self, tmp_path): |
| 347 | + """Explicit Copilot skills mode should not warn about the legacy default.""" |
| 348 | + from typer.testing import CliRunner |
| 349 | + from specify_cli import app |
| 350 | + project = tmp_path / "skills-no-warning" |
| 351 | + project.mkdir() |
| 352 | + old_cwd = os.getcwd() |
| 353 | + try: |
| 354 | + os.chdir(project) |
| 355 | + with warnings.catch_warnings(record=True) as caught: |
| 356 | + warnings.simplefilter("always") |
| 357 | + result = CliRunner().invoke(app, [ |
| 358 | + "init", "--here", "--integration", "copilot", |
| 359 | + "--integration-options", "--skills", "--script", "sh", |
| 360 | + ], catch_exceptions=False) |
| 361 | + finally: |
| 362 | + os.chdir(old_cwd) |
| 363 | + |
| 364 | + assert result.exit_code == 0, result.output |
| 365 | + assert not any( |
| 366 | + "Copilot legacy markdown mode is deprecated" in str(item.message) |
| 367 | + for item in caught |
| 368 | + ) |
| 369 | + |
298 | 370 |
|
299 | 371 | class TestCopilotSkillsMode: |
300 | 372 | """Tests for Copilot integration in --skills mode.""" |
|
0 commit comments