Skip to content

Commit 2719a8e

Browse files
committed
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 <[email protected]> Reviewed-by: Gavin Mak <[email protected]>
1 parent e4872ac commit 2719a8e

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

run_tests

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import functools
1919
import os
20+
import shlex
2021
import shutil
2122
import subprocess
2223
import sys
@@ -26,6 +27,11 @@ from typing import List
2627
ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
2728

2829

30+
def 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+
2935
@functools.lru_cache()
3036
def is_ci() -> bool:
3137
"""Whether we're running in our CI system."""
@@ -37,6 +43,7 @@ def run_pytest(argv: List[str]) -> int:
3743
if is_ci():
3844
argv = ["-m", "not skip_cq"] + argv
3945

46+
log_cmd("pytest", argv)
4047
return subprocess.run(
4148
[sys.executable, "-m", "pytest"] + argv,
4249
check=False,
@@ -49,6 +56,7 @@ def run_pytest_py38(argv: List[str]) -> int:
4956
if is_ci():
5057
argv = ["-m", "not skip_cq"] + argv
5158

59+
log_cmd("[vpython 3.8] pytest", argv)
5260
try:
5361
return subprocess.run(
5462
[
@@ -77,35 +85,43 @@ def run_black():
7785
"release/update-hooks",
7886
"release/update-manpages",
7987
]
88+
argv = ["--diff", "--check", ROOT_DIR] + extra_programs
89+
log_cmd("black", argv)
8090
return subprocess.run(
81-
[sys.executable, "-m", "black", "--check", ROOT_DIR] + extra_programs,
91+
[sys.executable, "-m", "black"] + argv,
8292
check=False,
8393
cwd=ROOT_DIR,
8494
).returncode
8595

8696

8797
def run_flake8():
8898
"""Returns the exit code from flake8."""
99+
argv = [ROOT_DIR]
100+
log_cmd("flake8", argv)
89101
return subprocess.run(
90-
[sys.executable, "-m", "flake8", ROOT_DIR],
102+
[sys.executable, "-m", "flake8"] + argv,
91103
check=False,
92104
cwd=ROOT_DIR,
93105
).returncode
94106

95107

96108
def run_isort():
97109
"""Returns the exit code from isort."""
110+
argv = ["--check", ROOT_DIR]
111+
log_cmd("isort", argv)
98112
return subprocess.run(
99-
[sys.executable, "-m", "isort", "--check", ROOT_DIR],
113+
[sys.executable, "-m", "isort"] + argv,
100114
check=False,
101115
cwd=ROOT_DIR,
102116
).returncode
103117

104118

105119
def run_check_metadata():
106120
"""Returns the exit code from check-metadata."""
121+
argv = []
122+
log_cmd("release/check-metadata.py", argv)
107123
return subprocess.run(
108-
[sys.executable, "release/check-metadata.py"],
124+
[sys.executable, "release/check-metadata.py"] + argv,
109125
check=False,
110126
cwd=ROOT_DIR,
111127
).returncode
@@ -118,8 +134,10 @@ def run_update_manpages() -> int:
118134
print("update-manpages: help2man not found; skipping test")
119135
return 0
120136

137+
argv = ["--check"]
138+
log_cmd("release/update-manpages", argv)
121139
return subprocess.run(
122-
[sys.executable, "release/update-manpages", "--check"],
140+
[sys.executable, "release/update-manpages"] + argv,
123141
check=False,
124142
cwd=ROOT_DIR,
125143
).returncode

0 commit comments

Comments
 (0)