summaryrefslogtreecommitdiffstats
path: root/run_tests
diff options
context:
space:
mode:
authorGavin Mak <gavinmak@google.com>2023-03-11 06:46:20 +0000
committerLUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-03-22 17:46:28 +0000
commitea2e330e43c182dc16b0111ebc69ee5a71ee4ce1 (patch)
treedc33ba0e56825b3e007d0589891756724725a465 /run_tests
parent1604cf255f8c1786a23388db6d5277ac7949a24a (diff)
downloadgit-repo-ea2e330e43c182dc16b0111ebc69ee5a71ee4ce1.tar.gz
Format codebase with black and check formatting in CQ
Apply rules set by https://gerrit-review.googlesource.com/c/git-repo/+/362954/ across the codebase and fix any lingering errors caught by flake8. Also check black formatting in run_tests (and CQ). Bug: b/267675342 Change-Id: I972d77649dac351150dcfeb1cd1ad0ea2efc1956 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/363474 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>
Diffstat (limited to 'run_tests')
-rwxr-xr-xrun_tests24
1 files changed, 21 insertions, 3 deletions
diff --git a/run_tests b/run_tests
index 0ea098a6..e76f9d8c 100755
--- a/run_tests
+++ b/run_tests
@@ -13,10 +13,28 @@
13# See the License for the specific language governing permissions and 13# See the License for the specific language governing permissions and
14# limitations under the License. 14# limitations under the License.
15 15
16"""Wrapper to run pytest with the right settings.""" 16"""Wrapper to run black and pytest with the right settings."""
17 17
18import os
19import subprocess
18import sys 20import sys
19import pytest 21import pytest
20 22
21if __name__ == '__main__': 23
22 sys.exit(pytest.main(sys.argv[1:])) 24def run_black():
25 """Returns the exit code of running `black --check`."""
26 dirpath = os.path.dirname(os.path.realpath(__file__))
27 return subprocess.run(
28 [sys.executable, "-m", "black", "--check", dirpath], check=False
29 ).returncode
30
31
32def main(argv):
33 """The main entry."""
34 black_ret = 0 if argv else run_black()
35 pytest_ret = pytest.main(argv)
36 return 0 if not black_ret and not pytest_ret else 1
37
38
39if __name__ == "__main__":
40 sys.exit(main(sys.argv[1:]))