Files
carbon-lang/toolchain/autoupdate_testdata.py
T
Richard Smith e469545eec Make autoupdate leave blaze-bin alone and produce less spam. (#3259)
Minor changes to the blaze command line executed by our autoupdate
scripts:

- Don't change the convenience symlinks. Running autoupdate shouldn't
cause `./bazel-bin/...` to switch to running a different binary.
- Don't produce so much spam. Bazel will still log its build progress if
necessary, and still report compile and runtime errors, but won't
produce half a dozen lines of INFO at the start of the command.
2023-10-03 18:56:25 +00:00

49 lines
1.3 KiB
Python
Executable File

#!/usr/bin/env python3
"""Autoupdates testdata in toolchain."""
__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:
argv = [
"bazel",
"run",
"-c",
"opt",
"--experimental_convenience_symlinks=ignore",
"--ui_event_filters=-info,-stdout,-stderr,-finish",
"//toolchain/testing:file_test",
"--",
"--autoupdate",
]
# Support specifying tests to update, such as:
# ./autoupdate_testdata.py lex/**/*
if len(sys.argv) > 1:
repo_root = Path(__file__).resolve().parent.parent
file_tests = []
# Filter down to just test files.
for f in sys.argv[1:]:
if f.endswith(".carbon"):
path = str(Path(f).resolve().relative_to(repo_root))
if path.count("/testdata/"):
file_tests.append(path)
if not file_tests:
sys.exit(
f"Args do not seem to be test files; for example, {sys.argv[1]}"
)
argv.append("--file_tests=" + ",".join(file_tests))
subprocess.run(argv, check=True)
if __name__ == "__main__":
main()