|
| 1 | +import os |
| 2 | +import subprocess |
| 3 | +import unittest |
| 4 | +from pathlib import Path |
| 5 | + |
| 6 | + |
| 7 | +REPO_ROOT = Path(__file__).resolve().parents[1] |
| 8 | +RUN_CODEX = REPO_ROOT / "ai" / "run-codex-solve-bug.sh" |
| 9 | +RUN_CLAUDE = REPO_ROOT / "ai" / "run-claude-solve-bug.sh" |
| 10 | +PROMPT = REPO_ROOT / "ai" / "solve_bug_issue.md" |
| 11 | +MANIFEST = REPO_ROOT / "ai" / "manifest.json" |
| 12 | + |
| 13 | + |
| 14 | +class TemplateSolveBugEntrypointsTests(unittest.TestCase): |
| 15 | + def test_prompt_contract(self) -> None: |
| 16 | + self.assertTrue(RUN_CODEX.is_file(), msg=f"missing file: {RUN_CODEX}") |
| 17 | + self.assertTrue(RUN_CLAUDE.is_file(), msg=f"missing file: {RUN_CLAUDE}") |
| 18 | + self.assertTrue(PROMPT.is_file(), msg=f"missing file: {PROMPT}") |
| 19 | + self.assertTrue(MANIFEST.is_file(), msg=f"missing file: {MANIFEST}") |
| 20 | + |
| 21 | + prompt = PROMPT.read_text(encoding="utf-8") |
| 22 | + manifest = MANIFEST.read_text(encoding="utf-8") |
| 23 | + |
| 24 | + self.assertIn("bash scripts/create-pr.sh", prompt) |
| 25 | + self.assertIn("bash scripts/monitor-pr-checks.sh", prompt) |
| 26 | + self.assertIn("effectively no open bug or bug-like issues", prompt) |
| 27 | + self.assertIn("run-codex-solve-bug.sh", manifest) |
| 28 | + self.assertIn("run-claude-solve-bug.sh", manifest) |
| 29 | + self.assertIn("solve_bug_issue.md", manifest) |
| 30 | + |
| 31 | + def test_run_codex_help(self) -> None: |
| 32 | + result = self._run_wrapper_help(RUN_CODEX) |
| 33 | + self.assertEqual(result.returncode, 0, msg=result.stderr) |
| 34 | + self.assertIn("--prompt", result.stdout) |
| 35 | + self.assertIn("--run-dir", result.stdout) |
| 36 | + self.assertIn("--text", result.stdout) |
| 37 | + |
| 38 | + def test_run_claude_help(self) -> None: |
| 39 | + result = self._run_wrapper_help(RUN_CLAUDE) |
| 40 | + self.assertEqual(result.returncode, 0, msg=result.stderr) |
| 41 | + self.assertIn("--prompt", result.stdout) |
| 42 | + self.assertIn("--run-dir", result.stdout) |
| 43 | + self.assertIn("--text", result.stdout) |
| 44 | + |
| 45 | + def _run_wrapper_help(self, source_script: Path) -> subprocess.CompletedProcess[str]: |
| 46 | + self.assertTrue(source_script.is_file(), msg=f"missing file: {source_script}") |
| 47 | + env = os.environ.copy() |
| 48 | + return subprocess.run( |
| 49 | + ["bash", str(source_script), "--help"], |
| 50 | + cwd=REPO_ROOT, |
| 51 | + text=True, |
| 52 | + capture_output=True, |
| 53 | + env=env, |
| 54 | + check=False, |
| 55 | + ) |
| 56 | + |
| 57 | + |
| 58 | +if __name__ == "__main__": |
| 59 | + unittest.main() |
0 commit comments