test_dialect_sync.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. """Guard the committed generated dialect against submodule drift."""
  2. import unittest
  3. from tools import gen_dialect
  4. from tools.gen_dialect import INCLUDES, SOURCE
  5. class DialectSyncTests(unittest.TestCase):
  6. def test_xml_sources_are_present(self):
  7. missing = [
  8. str(path)
  9. for path in (SOURCE, *(SOURCE.parent / name for name in INCLUDES))
  10. if not path.is_file()
  11. ]
  12. self.assertEqual(
  13. missing,
  14. [],
  15. "run `git submodule update --init --recursive` before testing",
  16. )
  17. def test_generated_dialect_is_up_to_date(self):
  18. if not gen_dialect.OUTPUT.is_file():
  19. self.fail(f"{gen_dialect.OUTPUT} is missing; run: python tools/gen_dialect.py")
  20. updated = gen_dialect.generate(dry_run=True, no_validate=True)
  21. self.assertFalse(
  22. updated,
  23. "motian_bridge/dialects/v20/VKFly.py is stale; regenerate with "
  24. "`.venv/bin/python tools/gen_dialect.py`",
  25. )
  26. if __name__ == "__main__":
  27. unittest.main()