Files
carbon-lang/toolchain/autoupdate_testdata.py
T
Jon Ross-Perkins 8aa3d960f5 Merge toolchain file_test children in order to improve linking. (#3206)
Specifically this should improve linking by producing one large binary
instead of one-per-directory. The inclusion of the driver hits the size
issue. Separating out things which have more llvm deps has been
discussed, but I'm not doing that here because I think the semantics
layer will need to depend on clang for interop, and we'd lose a lot of
the benefits that way. Also, having just one place to look seems
simpler.

Includes supporting changes to file_test infrastructure, the most
significant of which is probably passing tests via file instead of a
really large args thing, using a custom rule to do that. That's because
dealing with the layered filegroups that allow the toolchain setup is
more complicated, and this approach scales well.

Combined test time is ~9s, so not sharding right now.

I wasn't sure if people would prefer having the autoupdate script under
testing, so I left it alone for now.
2023-09-11 17:54:41 +00:00

47 lines
1.2 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",
"//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__).parent.parent
file_tests = []
# Filter down to just test files.
for f in sys.argv[1:]:
if f.endswith(".carbon"):
path = str(Path(f).absolute().relative_to(repo_root))
if path.find("/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()