summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2025-10-15 11:11:59 -0400
committerMike Frysinger <vapier@google.com>2025-10-15 11:09:48 -0700
commit2719a8e203e43b34a437b510092758870b81cae6 (patch)
tree0185008b2157d0823ff30ce2ee4adab7011f2acc
parente4872ac8baec782c86222ca93efb4a7c9b9e0c7b (diff)
downloadgit-repo-2719a8e203e43b34a437b510092758870b81cae6.tar.gz
run_tests: log each command run
This should make it clear to devs what commands are run and which fail in the CI. Change-Id: Ie863540cba6de7da933b4f32947ad09edee4aa45 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/519361 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com>
-rwxr-xr-xrun_tests28
1 files changed, 23 insertions, 5 deletions
diff --git a/run_tests b/run_tests
index 04f2deb4..2e1cddb5 100755
--- a/run_tests
+++ b/run_tests
@@ -17,6 +17,7 @@
17 17
18import functools 18import functools
19import os 19import os
20import shlex
20import shutil 21import shutil
21import subprocess 22import subprocess
22import sys 23import sys
@@ -26,6 +27,11 @@ from typing import List
26ROOT_DIR = os.path.dirname(os.path.realpath(__file__)) 27ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
27 28
28 29
30def log_cmd(cmd: str, argv: list[str]) -> None:
31 """Log a debug message to make history easier to track."""
32 print("+", cmd, shlex.join(argv), file=sys.stderr)
33
34
29@functools.lru_cache() 35@functools.lru_cache()
30def is_ci() -> bool: 36def is_ci() -> bool:
31 """Whether we're running in our CI system.""" 37 """Whether we're running in our CI system."""
@@ -37,6 +43,7 @@ def run_pytest(argv: List[str]) -> int:
37 if is_ci(): 43 if is_ci():
38 argv = ["-m", "not skip_cq"] + argv 44 argv = ["-m", "not skip_cq"] + argv
39 45
46 log_cmd("pytest", argv)
40 return subprocess.run( 47 return subprocess.run(
41 [sys.executable, "-m", "pytest"] + argv, 48 [sys.executable, "-m", "pytest"] + argv,
42 check=False, 49 check=False,
@@ -49,6 +56,7 @@ def run_pytest_py38(argv: List[str]) -> int:
49 if is_ci(): 56 if is_ci():
50 argv = ["-m", "not skip_cq"] + argv 57 argv = ["-m", "not skip_cq"] + argv
51 58
59 log_cmd("[vpython 3.8] pytest", argv)
52 try: 60 try:
53 return subprocess.run( 61 return subprocess.run(
54 [ 62 [
@@ -77,8 +85,10 @@ def run_black():
77 "release/update-hooks", 85 "release/update-hooks",
78 "release/update-manpages", 86 "release/update-manpages",
79 ] 87 ]
88 argv = ["--diff", "--check", ROOT_DIR] + extra_programs
89 log_cmd("black", argv)
80 return subprocess.run( 90 return subprocess.run(
81 [sys.executable, "-m", "black", "--check", ROOT_DIR] + extra_programs, 91 [sys.executable, "-m", "black"] + argv,
82 check=False, 92 check=False,
83 cwd=ROOT_DIR, 93 cwd=ROOT_DIR,
84 ).returncode 94 ).returncode
@@ -86,8 +96,10 @@ def run_black():
86 96
87def run_flake8(): 97def run_flake8():
88 """Returns the exit code from flake8.""" 98 """Returns the exit code from flake8."""
99 argv = [ROOT_DIR]
100 log_cmd("flake8", argv)
89 return subprocess.run( 101 return subprocess.run(
90 [sys.executable, "-m", "flake8", ROOT_DIR], 102 [sys.executable, "-m", "flake8"] + argv,
91 check=False, 103 check=False,
92 cwd=ROOT_DIR, 104 cwd=ROOT_DIR,
93 ).returncode 105 ).returncode
@@ -95,8 +107,10 @@ def run_flake8():
95 107
96def run_isort(): 108def run_isort():
97 """Returns the exit code from isort.""" 109 """Returns the exit code from isort."""
110 argv = ["--check", ROOT_DIR]
111 log_cmd("isort", argv)
98 return subprocess.run( 112 return subprocess.run(
99 [sys.executable, "-m", "isort", "--check", ROOT_DIR], 113 [sys.executable, "-m", "isort"] + argv,
100 check=False, 114 check=False,
101 cwd=ROOT_DIR, 115 cwd=ROOT_DIR,
102 ).returncode 116 ).returncode
@@ -104,8 +118,10 @@ def run_isort():
104 118
105def run_check_metadata(): 119def run_check_metadata():
106 """Returns the exit code from check-metadata.""" 120 """Returns the exit code from check-metadata."""
121 argv = []
122 log_cmd("release/check-metadata.py", argv)
107 return subprocess.run( 123 return subprocess.run(
108 [sys.executable, "release/check-metadata.py"], 124 [sys.executable, "release/check-metadata.py"] + argv,
109 check=False, 125 check=False,
110 cwd=ROOT_DIR, 126 cwd=ROOT_DIR,
111 ).returncode 127 ).returncode
@@ -118,8 +134,10 @@ def run_update_manpages() -> int:
118 print("update-manpages: help2man not found; skipping test") 134 print("update-manpages: help2man not found; skipping test")
119 return 0 135 return 0
120 136
137 argv = ["--check"]
138 log_cmd("release/update-manpages", argv)
121 return subprocess.run( 139 return subprocess.run(
122 [sys.executable, "release/update-manpages", "--check"], 140 [sys.executable, "release/update-manpages"] + argv,
123 check=False, 141 check=False,
124 cwd=ROOT_DIR, 142 cwd=ROOT_DIR,
125 ).returncode 143 ).returncode