summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2025-03-25 12:23:05 -0400
committerMike Frysinger <vapier@google.com>2025-03-25 10:08:54 -0700
commitd5087392edcee3c0da4ba19efb6005efd9ccf706 (patch)
treeab80a06b95dece2bd2d43ace2fb933d8bb9be0f6
parent91f428058d7d23709c057850580fe0315bd74f76 (diff)
downloadgit-repo-d5087392edcee3c0da4ba19efb6005efd9ccf706.tar.gz
run_tests: move CQ test skips here
Our recipes have been disabling a bunch of tests. To increase visibility, and to make it easier to test changes, move that logic to this script. Change-Id: I3894f047715177c0f1d27a2fe4c3490972dab204 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/462881 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com>
-rwxr-xr-xrun_tests31
1 files changed, 30 insertions, 1 deletions
diff --git a/run_tests b/run_tests
index bb7ca915..bdf383eb 100755
--- a/run_tests
+++ b/run_tests
@@ -15,9 +15,11 @@
15 15
16"""Wrapper to run linters and pytest with the right settings.""" 16"""Wrapper to run linters and pytest with the right settings."""
17 17
18import functools
18import os 19import os
19import subprocess 20import subprocess
20import sys 21import sys
22from typing import List
21 23
22import pytest 24import pytest
23 25
@@ -25,6 +27,33 @@ import pytest
25ROOT_DIR = os.path.dirname(os.path.realpath(__file__)) 27ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
26 28
27 29
30@functools.lru_cache()
31def is_ci() -> bool:
32 """Whether we're running in our CI system."""
33 return os.getenv("LUCI_CQ") == "yes"
34
35
36def run_pytest(argv: List[str]) -> int:
37 """Returns the exit code from pytest."""
38 if is_ci():
39 # TODO(b/266734831): Find out why smoke tests fail.
40 # TODO(b/266734831): Find out why each superproject test takes 8m+.
41 tests_to_skip = (
42 "test_smoke_repo",
43 "test_smoke_git",
44 "test_superproject_get_superproject_invalid_branch",
45 "test_superproject_get_superproject_invalid_url",
46 )
47
48 print("WARNING: Skipping tests:", tests_to_skip)
49 argv = [
50 "-k",
51 " and ".join(f"not {x}" for x in tests_to_skip),
52 ] + argv
53
54 return pytest.main(argv)
55
56
28def run_black(): 57def run_black():
29 """Returns the exit code from black.""" 58 """Returns the exit code from black."""
30 # Black by default only matches .py files. We have to list standalone 59 # Black by default only matches .py files. We have to list standalone
@@ -58,7 +87,7 @@ def run_isort():
58def main(argv): 87def main(argv):
59 """The main entry.""" 88 """The main entry."""
60 checks = ( 89 checks = (
61 lambda: pytest.main(argv), 90 functools.partial(run_pytest, argv),
62 run_black, 91 run_black,
63 run_flake8, 92 run_flake8,
64 run_isort, 93 run_isort,