mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-03-31 14:09:28 +00:00
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>
This commit is contained in:
parent
91f428058d
commit
d5087392ed
31
run_tests
31
run_tests
@ -15,9 +15,11 @@
|
||||
|
||||
"""Wrapper to run linters and pytest with the right settings."""
|
||||
|
||||
import functools
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from typing import List
|
||||
|
||||
import pytest
|
||||
|
||||
@ -25,6 +27,33 @@ import pytest
|
||||
ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
|
||||
@functools.lru_cache()
|
||||
def is_ci() -> bool:
|
||||
"""Whether we're running in our CI system."""
|
||||
return os.getenv("LUCI_CQ") == "yes"
|
||||
|
||||
|
||||
def run_pytest(argv: List[str]) -> int:
|
||||
"""Returns the exit code from pytest."""
|
||||
if is_ci():
|
||||
# TODO(b/266734831): Find out why smoke tests fail.
|
||||
# TODO(b/266734831): Find out why each superproject test takes 8m+.
|
||||
tests_to_skip = (
|
||||
"test_smoke_repo",
|
||||
"test_smoke_git",
|
||||
"test_superproject_get_superproject_invalid_branch",
|
||||
"test_superproject_get_superproject_invalid_url",
|
||||
)
|
||||
|
||||
print("WARNING: Skipping tests:", tests_to_skip)
|
||||
argv = [
|
||||
"-k",
|
||||
" and ".join(f"not {x}" for x in tests_to_skip),
|
||||
] + argv
|
||||
|
||||
return pytest.main(argv)
|
||||
|
||||
|
||||
def run_black():
|
||||
"""Returns the exit code from black."""
|
||||
# Black by default only matches .py files. We have to list standalone
|
||||
@ -58,7 +87,7 @@ def run_isort():
|
||||
def main(argv):
|
||||
"""The main entry."""
|
||||
checks = (
|
||||
lambda: pytest.main(argv),
|
||||
functools.partial(run_pytest, argv),
|
||||
run_black,
|
||||
run_flake8,
|
||||
run_isort,
|
||||
|
Loading…
x
Reference in New Issue
Block a user