import pathlib import subprocess import sys import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from repo_checks import ROOT GENERATED = [ "bin/__pycache__/a.cpython-313.pyc", "bin/agent_cycle/__pycache__/a.cpython-313.pyc", "workflow-bench/a-1-1.md", "workflow-bench/a-1-1/README.md", "workflow-bench/compare/a/A1/fixes.diff", "workflow-bench/logs/a.jsonl", ] AUTHORED = [ "bin/agent_cycle/run.py", "workflow-bench/advisor-judge-prompt.md", "workflow-bench/bench.py", "workflow-bench/setup.cfg", ] class Gitignore(unittest.TestCase): def test_ignores_no_tracked_file(self): ignored = subprocess.run(["git", "ls-files", "-ci", "--exclude-standard"], capture_output=True, check=True, cwd=ROOT, text=True).stdout self.assertEqual(ignored, "") def test_ignores_no_python_module_or_test_under_bin(self): ignored = subprocess.run(["git", "ls-files", "-oi", "--exclude-standard", "--", "bin/*.py", "bin/**/*.py"], capture_output=True, check=True, cwd=ROOT, text=True).stdout self.assertEqual(ignored, "") def test_ignores_every_generated_file(self): ignored = subprocess.run(["git", "check-ignore", "--no-index", "--stdin"], capture_output=True, cwd=ROOT, input="\n".join(GENERATED), text=True).stdout self.assertEqual(ignored.splitlines(), GENERATED) def test_ignores_no_authored_file(self): ignored = subprocess.run(["git", "check-ignore", "--no-index", "--stdin"], capture_output=True, cwd=ROOT, input="\n".join(AUTHORED), text=True).stdout self.assertEqual(ignored, "")