lit_autoupdate.py 978 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env python3
  2. """Updates the CHECK: lines in lit tests based on the AUTOUPDATE line."""
  3. __copyright__ = """
  4. Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  5. Exceptions. See /LICENSE for license information.
  6. SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. """
  8. import os
  9. import sys
  10. from pathlib import Path
  11. def main() -> None:
  12. # Calls the main script using execv in order to avoid Python import
  13. # behaviors.
  14. this_py = Path(__file__).resolve()
  15. actual_py = this_py.parent.parent.parent.joinpath(
  16. "bazel", "testing", "lit_autoupdate_base.py"
  17. )
  18. args = [
  19. sys.argv[0],
  20. # Flags to configure for parser testing.
  21. "--tool=carbon",
  22. "--autoupdate_arg=dump",
  23. "--autoupdate_arg=parse-tree",
  24. "--lit_run=%{carbon-run-parser}",
  25. "--testdata=toolchain/parser/testdata",
  26. ] + sys.argv[1:]
  27. os.execv(actual_py, args)
  28. if __name__ == "__main__":
  29. main()