decorate_unit_tests.py 958 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env sentry exec
  2. from __future__ import annotations
  3. from scripts.silo.add_silo_decorators import SILO_KEYWORDS
  4. from sentry.utils.silo.decorate_unit_tests import decorate_unit_tests
  5. """Add silo mode decorators to unit test cases en masse.
  6. Unlike `add_silo_decorators`, this script can't really reflect on interpreted
  7. Python code in order to distinguish unit tests. It instead relies on an external
  8. `pytest` run to collect the list of test cases, and does some kludgey regex
  9. business in order to apply the decorators.
  10. Instructions for use:
  11. From the Sentry project root, do
  12. pytest --collect-only | ./scripts/silo/decorate_unit_tests.py
  13. Running `pytest` to collect unit test cases can be quite slow. To speed up
  14. repeated runs, you can instead do
  15. pytest --collect-only > pytest-collect.txt
  16. ./scripts/silo/decorate_unit_tests.py < pytest-collect.txt
  17. """
  18. if __name__ == "__main__":
  19. decorate_unit_tests(silo_keywords=SILO_KEYWORDS)