From d5087392edcee3c0da4ba19efb6005efd9ccf706 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 25 Mar 2025 12:23:05 -0400 Subject: [PATCH] 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 Reviewed-by: Gavin Mak --- run_tests | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/run_tests b/run_tests index bb7ca915..bdf383eb 100755 --- a/run_tests +++ b/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,