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 <vapier@google.com>
Commit-Queue: Mike Frysinger <vapier@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
This commit is contained in:
Mike Frysinger authored and gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com committed 2026-11-11 15:34:09 -08:00
1 parent bb9b4c2b60
commit 2b7969d1cf
5 files changed
+27 -3

No files matched your search

Symlink
+1
View File
@@ -0,0 +1 @@
run_tests
Symlink
+1
View File
@@ -0,0 +1 @@
run_tests
Symlink
+1
View File
@@ -0,0 +1 @@
run_tests
Symlink
+1
View File
@@ -0,0 +1 @@
run_tests
+23 -3
View File
@@ -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:]))