Files
carbon-lang/toolchain/parser/autoupdate_testdata.py
T
Jon Ross-Perkins 735502273b Refactor lit test infra under //testing. (#2829)
- 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.
2023-05-18 08:01:03 -07:00

35 lines
945 B
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 parser testing.
"--tool=carbon",
"--autoupdate_arg=dump",
"--autoupdate_arg=parse-tree",
"--testdata=toolchain/parser/testdata",
] + sys.argv[1:]
exit(subprocess.call(args))
if __name__ == "__main__":
main()