lit_autoupdate.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 lexer testing.
  21. "--tool=carbon",
  22. "--autoupdate_arg=dump",
  23. "--autoupdate_arg=tokens",
  24. # Ignore the resulting column of EndOfFile because it's typically the
  25. # end of the CHECK comment.
  26. "--extra_check_replacement",
  27. ".*'EndOfFile'",
  28. r"column: (?:\d+)",
  29. "column: {{[0-9]+}}",
  30. # Ignore spaces that are used to columnize lines.
  31. "--line_number_delta_prefix={{ *}}",
  32. "--line_number_pattern="
  33. r"(?P<prefix> line: )(?P<line> *\d+)(?P<suffix>,)",
  34. "--lit_run=%{carbon-run-tokens}",
  35. "--testdata=toolchain/lexer/testdata",
  36. ] + sys.argv[1:]
  37. os.execv(actual_py, args)
  38. if __name__ == "__main__":
  39. main()