Stress test for lint cache systems.
| 29 | |
| 30 | |
| 31 | class CacheLintStressTest: |
| 32 | """Stress test for lint cache systems.""" |
| 33 | |
| 34 | def __init__(self): |
| 35 | self.passed = 0 |
| 36 | self.failed = 0 |
| 37 | self.errors: list[str] = [] |
| 38 | self.manifest = DependencyManifest() |
| 39 | |
| 40 | def pass_test(self, name: str): |
| 41 | self.passed += 1 |
| 42 | print(f" ✅ {name}") |
| 43 | |
| 44 | def fail_test(self, name: str, error: str): |
| 45 | self.failed += 1 |
| 46 | self.errors.append(f"{name}: {error}") |
| 47 | print(f" ❌ {name}: {error}") |
| 48 | |
| 49 | def run_cache_check(self, cache_type: str) -> tuple[bool, str]: |
| 50 | """Run a cache check script and return (needs_run, output).""" |
| 51 | scripts = { |
| 52 | "python": "ci/python_lint_cache.py", |
| 53 | "js": "ci/js_lint_cache.py", |
| 54 | "cpp": "ci/cpp_lint_cache.py", |
| 55 | } |
| 56 | |
| 57 | if cache_type not in scripts: |
| 58 | return False, f"Unknown cache type: {cache_type}" |
| 59 | |
| 60 | script = scripts[cache_type] |
| 61 | try: |
| 62 | result = subprocess.run( |
| 63 | ["uv", "run", "python", script, "check"], |
| 64 | capture_output=True, |
| 65 | text=True, |
| 66 | encoding="utf-8", |
| 67 | errors="replace", |
| 68 | timeout=10, |
| 69 | ) |
| 70 | # Exit code 0 = needs update, 1 = skip (cache hit) |
| 71 | needs_update = result.returncode == 0 |
| 72 | output = result.stdout + result.stderr |
| 73 | return needs_update, output |
| 74 | except KeyboardInterrupt as ki: |
| 75 | handle_keyboard_interrupt(ki) |
| 76 | raise |
| 77 | except Exception as e: |
| 78 | return False, str(e) |
| 79 | |
| 80 | def run_cache_mark(self, cache_type: str) -> tuple[bool, str]: |
| 81 | """Mark cache as successful.""" |
| 82 | scripts = { |
| 83 | "python": "ci/python_lint_cache.py", |
| 84 | "js": "ci/js_lint_cache.py", |
| 85 | "cpp": "ci/cpp_lint_cache.py", |
| 86 | } |
| 87 | |
| 88 | if cache_type not in scripts: |