mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-04-02 14:09:18 +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."""
|
"""Wrapper to run linters and pytest with the right settings."""
|
||||||
|
|
||||||
|
import functools
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
from typing import List
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@ -25,6 +27,33 @@ import pytest
|
|||||||
ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
|
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():
|
def run_black():
|
||||||
"""Returns the exit code from black."""
|
"""Returns the exit code from black."""
|
||||||
# Black by default only matches .py files. We have to list standalone
|
# Black by default only matches .py files. We have to list standalone
|
||||||
@ -58,7 +87,7 @@ def run_isort():
|
|||||||
def main(argv):
|
def main(argv):
|
||||||
"""The main entry."""
|
"""The main entry."""
|
||||||
checks = (
|
checks = (
|
||||||
lambda: pytest.main(argv),
|
functools.partial(run_pytest, argv),
|
||||||
run_black,
|
run_black,
|
||||||
run_flake8,
|
run_flake8,
|
||||||
run_isort,
|
run_isort,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user