diff options
author | Mike Frysinger <vapier@google.com> | 2025-03-25 12:23:05 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2025-03-25 10:08:54 -0700 |
commit | d5087392edcee3c0da4ba19efb6005efd9ccf706 (patch) | |
tree | ab80a06b95dece2bd2d43ace2fb933d8bb9be0f6 | |
parent | 91f428058d7d23709c057850580fe0315bd74f76 (diff) | |
download | git-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-x | run_tests | 31 |
1 files changed, 30 insertions, 1 deletions
@@ -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 | ||
18 | import functools | ||
18 | import os | 19 | import os |
19 | import subprocess | 20 | import subprocess |
20 | import sys | 21 | import sys |
22 | from typing import List | ||
21 | 23 | ||
22 | import pytest | 24 | import pytest |
23 | 25 | ||
@@ -25,6 +27,33 @@ import pytest | |||
25 | ROOT_DIR = os.path.dirname(os.path.realpath(__file__)) | 27 | ROOT_DIR = os.path.dirname(os.path.realpath(__file__)) |
26 | 28 | ||
27 | 29 | ||
30 | @functools.lru_cache() | ||
31 | def is_ci() -> bool: | ||
32 | """Whether we're running in our CI system.""" | ||
33 | return os.getenv("LUCI_CQ") == "yes" | ||
34 | |||
35 | |||
36 | def 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 | |||
28 | def run_black(): | 57 | def 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(): | |||
58 | def main(argv): | 87 | def 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, |