Skip to content

Commit d508739

Browse files
committed
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 <[email protected]> Reviewed-by: Gavin Mak <[email protected]>
1 parent 91f4280 commit d508739

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

run_tests

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,45 @@
1515

1616
"""Wrapper to run linters and pytest with the right settings."""
1717

18+
import functools
1819
import os
1920
import subprocess
2021
import sys
22+
from typing import List
2123

2224
import pytest
2325

2426

2527
ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
2628

2729

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+
2857
def run_black():
2958
"""Returns the exit code from black."""
3059
# Black by default only matches .py files. We have to list standalone
@@ -58,7 +87,7 @@ def run_isort():
5887
def main(argv):
5988
"""The main entry."""
6089
checks = (
61-
lambda: pytest.main(argv),
90+
functools.partial(run_pytest, argv),
6291
run_black,
6392
run_flake8,
6493
run_isort,

0 commit comments

Comments
 (0)