diff --git a/toolchain/autoupdate_testdata.py b/toolchain/autoupdate_testdata.py index 64abdc1f37b8..84e4483d0c8a 100755 --- a/toolchain/autoupdate_testdata.py +++ b/toolchain/autoupdate_testdata.py @@ -21,6 +21,19 @@ from pathlib import Path def main() -> None: + # Parse arguments. + parser = argparse.ArgumentParser(__doc__) + parser.add_argument("--non-fatal-checks", action="store_true") + parser.add_argument( + "--print_slowest_tests", default=0, help="Forwarded to file_test" + ) + parser.add_argument("--threads", help="Forwarded to file_test") + parser.add_argument( + "--verbose", "-v", action="store_true", help="Produce verbose output" + ) + parser.add_argument("files", nargs="*") + args = parser.parse_args() + bazel = str(Path(__file__).parents[1] / "scripts" / "run_bazel.py") configs = [] # Use the most recently used build mode, or `fastbuild` if missing @@ -41,18 +54,14 @@ def main() -> None: m = re.search(r"-(\w+)/bin$", link) if m: build_mode = m[1] + print(f"Detected --compilation_mode: {build_mode}") else: exit(f"Build mode not found in `bazel-bin` symlink: {link}") - - # Parse arguments. - parser = argparse.ArgumentParser(__doc__) - parser.add_argument("--non-fatal-checks", action="store_true") - parser.add_argument( - "--print_slowest_tests", default=0, help="Forwarded to file_test" - ) - parser.add_argument("--threads", help="Forwarded to file_test") - parser.add_argument("files", nargs="*") - args = parser.parse_args() + elif args.verbose: + print( + "Detected --compilation_mode: none (no `./bazel-bin`), " + + f"falling back to {build_mode}" + ) if args.non_fatal_checks: if build_mode == "optimize": @@ -95,6 +104,8 @@ def main() -> None: f"{args.files[0]}" ) argv.append("--file_tests=" + ",".join(file_tests)) + if args.verbose: + print(shlex.join(argv)) # Provide an empty stdin so that the driver tests that read from stdin # don't block waiting for input. This matches the behavior of `bazel test`. result = subprocess.run(argv)