From 2aa313a4e00ad9cf88d8fc541dea614f7ce29d1e Mon Sep 17 00:00:00 2001 From: Yuhuan He Date: Thu, 15 Oct 2026 14:52:24 -0700 Subject: [PATCH] fix(tests): ignore cache files when finding script-bearing skills script_bearing_skills() counted a skill as shipping scripts when anything at all existed under scripts/, including gitignored __pycache__/ left by running a script by hand. A local checkout where parallel-web (which ships no scripts) had a stale scripts/__pycache__/ then failed test_every_skill_with_scripts_has_a_test_suite, even though a clean checkout passes. Count only real files, skipping bytecode, __pycache__ and dotfiles such as .DS_Store. Paths are checked relative to scripts/, so a checkout under a dot-directory is unaffected. On a clean tree the result matches the set of skills with git-tracked scripts (121). Co-Authored-By: Claude Opus 5.5 (1M context) --- tests/_contract/structure.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/_contract/structure.py b/tests/_contract/structure.py index ee28d661..2f2bf7c2 100644 --- a/tests/_contract/structure.py +++ b/tests/_contract/structure.py @@ -82,17 +82,32 @@ def script_bearing_skills(skills_dir: Path = SKILLS_DIR) -> list[Path]: An empty `scripts/` directory does not count. Git cannot track empty directories, so one only ever exists as local cruft, and requiring a test - suite for a skill that ships no scripts would be nonsense. + suite for a skill that ships no scripts would be nonsense. The same goes + for a `scripts/` that holds only gitignored leftovers, such as the + `__pycache__/` a script run leaves behind or a `.DS_Store`. """ return [ skill for skill in sorted(skills_dir.iterdir()) if skill.is_dir() and (skill / "SKILL.md").is_file() - and any((skill / "scripts").rglob("*")) + and _ships_script_files(skill / "scripts") ] +def _ships_script_files(scripts: Path) -> bool: + """`scripts/` holds a file that is not bytecode, a cache, or a dotfile.""" + return any( + path.is_file() + and path.suffix not in {".pyc", ".pyo"} + and not any( + part == "__pycache__" or part.startswith(".") + for part in path.relative_to(scripts).parts + ) + for path in scripts.rglob("*") + ) + + def all_skill_names(skills_dir: Path = SKILLS_DIR) -> set[str]: return { skill.name