Skip to content

Commit 2b44ad2

Browse files
test: cover the fallback scan branch for the --- SKILL.md parse
Copilot noted the new regression test only exercised the fast removal path (skills_project keeps ai_skills enabled, so remove() resolves the skills dir directly). Add test_skills_removed_with_dashes_via_fallback_scan, which deletes init-options.json after install so _get_skills_dir() returns None and removal takes the fallback directory-scan branch. That branch re-reads metadata.source with an independently duplicated parser; reverting it to the old substring split now fails this test (dir orphaned) while the fast-path test still passes.
1 parent 6397528 commit 2b44ad2

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

tests/test_extension_skills.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,6 +1740,35 @@ def test_skills_removed_when_description_contains_dashes(
17401740
# The extension's own skill must be recognised and removed, not orphaned.
17411741
assert not skill_dir.exists()
17421742

1743+
def test_skills_removed_with_dashes_via_fallback_scan(
1744+
self, skills_project, temp_dir
1745+
):
1746+
"""Same ``---`` guard, but exercised through the fallback scan branch.
1747+
1748+
The fast path resolves the skills dir from init-options; the fallback
1749+
branch scans every candidate agent dir when that resolution returns
1750+
None, and it re-reads metadata.source with an independently duplicated
1751+
parser. Deleting init-options.json after install forces removal down
1752+
the fallback path so a substring-split regression there is caught too.
1753+
"""
1754+
project_dir, skills_dir = skills_project
1755+
ext_dir = _create_dashed_description_extension_dir(temp_dir)
1756+
manager = ExtensionManager(project_dir)
1757+
manifest = manager.install_from_directory(
1758+
ext_dir, "0.1.0", register_commands=False
1759+
)
1760+
1761+
skill_dir = skills_dir / "speckit-dash-ext-hello"
1762+
assert (skill_dir / "SKILL.md").exists()
1763+
1764+
# Drop init-options so _get_skills_dir() returns None and removal takes
1765+
# the fallback directory-scan branch instead of the fast path.
1766+
(project_dir / ".specify" / "init-options.json").unlink()
1767+
1768+
result = manager.remove(manifest.id, keep_config=False)
1769+
assert result is True
1770+
assert not skill_dir.exists()
1771+
17431772
def test_other_skills_preserved_on_remove(self, skills_project, extension_dir):
17441773
"""Non-extension skills should not be affected by extension removal."""
17451774
project_dir, skills_dir = skills_project

0 commit comments

Comments
 (0)