test_cache_reporting.py 980 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env python3
  2. """AST-only check: do not import boot.py (it has runtime side effects)."""
  3. import ast
  4. import unittest
  5. from pathlib import Path
  6. ROOT = Path(__file__).resolve().parents[1]
  7. class CacheReportingTests(unittest.TestCase):
  8. def test_unconditional_sglang_flag(self):
  9. tree = ast.parse((ROOT / "boot.py").read_text())
  10. base_args = [
  11. node.value for node in ast.walk(tree)
  12. if isinstance(node, ast.Assign)
  13. and any(isinstance(t, ast.Name) and t.id == "args" for t in node.targets)
  14. and isinstance(node.value, ast.List)
  15. ]
  16. self.assertEqual(len(base_args), 1)
  17. flags = [n.value for n in base_args[0].elts if isinstance(n, ast.Constant)]
  18. self.assertEqual(flags.count("--enable-cache-report"), 1)
  19. self.assertNotIn("--enable-prompt-tokens-details", flags)
  20. self.assertNotIn("--enable-prompt-token-details", flags)
  21. if __name__ == "__main__":
  22. unittest.main()