From 2b7969d1cfce419a53139148cc7654467c8d2dee Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 11 Nov 2026 15:00:15 -0500 Subject: [PATCH] run_tests: turn into multicall program Add shortcuts to easily run individual tools while re-using the embedded vpython/UV script settings. Change-Id: I4c63e7fd402666628a18cc77187c958d93910f80 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/656245 Tested-by: Mike Frysinger Commit-Queue: Mike Frysinger Reviewed-by: Gavin Mak --- black | 1 + flake8 | 1 + isort | 1 + pytest | 1 + run_tests | 26 +++++++++++++++++++++++--- 5 files changed, 27 insertions(+), 3 deletions(-) create mode 120000 black create mode 120000 flake8 create mode 120000 isort create mode 120000 pytest diff --git a/black b/black new file mode 120000 index 000000000..934c8cd80 --- /dev/null +++ b/black @@ -0,0 +1 @@ +run_tests \ No newline at end of file diff --git a/flake8 b/flake8 new file mode 120000 index 000000000..934c8cd80 --- /dev/null +++ b/flake8 @@ -0,0 +1 @@ +run_tests \ No newline at end of file diff --git a/isort b/isort new file mode 120000 index 000000000..934c8cd80 --- /dev/null +++ b/isort @@ -0,0 +1 @@ +run_tests \ No newline at end of file diff --git a/pytest b/pytest new file mode 120000 index 000000000..934c8cd80 --- /dev/null +++ b/pytest @@ -0,0 +1 @@ +run_tests \ No newline at end of file diff --git a/run_tests b/run_tests index 3ce0dac35..21af64f10 100755 --- a/run_tests +++ b/run_tests @@ -34,10 +34,14 @@ import functools import os import shlex -import shutil import subprocess import sys +import black +import flake8.main.cli +import isort.main +import pytest + # NB: While tests/* support Python >=3.6 to match requirements.json for `repo`, # the higher level runner logic does not need to be held back. @@ -202,8 +206,8 @@ def cipd_bootstrap() -> None: return -def main(argv): - """The main entry.""" +def main_run_tests(argv: list[str]) -> int: + """The run_tests program.""" cipd_bootstrap() checks = ( functools.partial(run_pytest, argv), @@ -219,5 +223,21 @@ def main(argv): return 1 if sum(c() for c in checks) else 0 +main_black = black.main +main_flake8 = flake8.main.cli.main +main_isort = isort.main.main +main_pytest = pytest.main + + +def main(argv: list[str]) -> int: + """The main dispatcher.""" + # Figure out what script we're running as and dispatch to its main. + # This makes it easier for people to use the same env as run_tests. + argv0 = os.path.basename(sys.argv[0]) + funcname = f"main_{argv0}" + func = globals().get(funcname, main_run_tests) + return func(argv) + + if __name__ == "__main__": sys.exit(main(sys.argv[1:]))