mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-17 12:38:10 +00:00
- Moves most parts to //testing/lit_test to be consistent with //testing/file_test. - Separates the autoupdate script out because it's shared between lit_test and file_test now, not lit-specific. - Renames scripts to autoupdate_testdata (or autoupdate_lit_testdata for explorer's extra) to be more consistent with the non-lit-specific setup. - Switches from execv to subprocess.call to head off a subtle issue regarding execution of multiple scripts, which we're likely to want in the future. Mostly in this PR because everything was already being touched. - Removes autoupdate's dependency on merge_output in order to (a) better support the division of lit and non-lit logic and (b) remove a subprocess, for reasons similar to file_test's removal of subprocesses.
45 lines
1.3 KiB
Python
Executable File
45 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
"""Updates the CHECK: lines in tests with an AUTOUPDATE line."""
|
|
|
|
__copyright__ = """
|
|
Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
Exceptions. See /LICENSE for license information.
|
|
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
"""
|
|
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def main() -> None:
|
|
# Subprocess to the main script in order to avoid Python import behaviors.
|
|
this_py = Path(__file__).resolve()
|
|
autoupdate_py = this_py.parent.parent.parent.joinpath(
|
|
"testing", "scripts", "autoupdate_testdata_base.py"
|
|
)
|
|
args = [
|
|
str(autoupdate_py),
|
|
# Flags to configure for lexer testing.
|
|
"--tool=carbon",
|
|
"--autoupdate_arg=dump",
|
|
"--autoupdate_arg=tokens",
|
|
# Ignore the resulting column of EndOfFile because it's typically the
|
|
# end of the CHECK comment.
|
|
"--extra_check_replacement",
|
|
".*'EndOfFile'",
|
|
r"column: (?:\d+)",
|
|
"column: {{[0-9]+}}",
|
|
# Ignore spaces that are used to columnize lines.
|
|
"--line_number_delta_prefix={{ *}}",
|
|
"--line_number_pattern="
|
|
r"(?P<prefix> line: )(?P<line> *\d+)(?P<suffix>,)",
|
|
"--testdata=toolchain/lexer/testdata",
|
|
] + sys.argv[1:]
|
|
exit(subprocess.call(args))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|