mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-06-26 20:17:52 +00:00
run_tests: move test filtering to pytest markers
Move the test disable logic even closer to the exact test that's disabled. This way people updating tests have a better chance of seeing they'll get reduced coverage in the CQ. Change-Id: I57c1a073a844019798b27e14d742fd32925d9ae8 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/462882 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Mike Frysinger <vapier@google.com>
This commit is contained in:
@ -16,3 +16,8 @@
|
|||||||
line-length = 80
|
line-length = 80
|
||||||
# NB: Keep in sync with tox.ini.
|
# NB: Keep in sync with tox.ini.
|
||||||
target-version = ['py36', 'py37', 'py38', 'py39', 'py310', 'py311'] #, 'py312'
|
target-version = ['py36', 'py37', 'py38', 'py39', 'py310', 'py311'] #, 'py312'
|
||||||
|
|
||||||
|
[tool.pytest.ini_options]
|
||||||
|
markers = """
|
||||||
|
skip_cq: Skip tests in the CQ. Should be rarely used!
|
||||||
|
"""
|
||||||
|
15
run_tests
15
run_tests
@ -36,20 +36,7 @@ def is_ci() -> bool:
|
|||||||
def run_pytest(argv: List[str]) -> int:
|
def run_pytest(argv: List[str]) -> int:
|
||||||
"""Returns the exit code from pytest."""
|
"""Returns the exit code from pytest."""
|
||||||
if is_ci():
|
if is_ci():
|
||||||
# TODO(b/266734831): Find out why smoke tests fail.
|
argv = ["-m", "not skip_cq"] + argv
|
||||||
# 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)
|
return pytest.main(argv)
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@ import subprocess
|
|||||||
import unittest
|
import unittest
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
import git_command
|
import git_command
|
||||||
import wrapper
|
import wrapper
|
||||||
|
|
||||||
@ -263,6 +265,7 @@ class UserAgentUnitTest(unittest.TestCase):
|
|||||||
m = re.match(r"^[^ ]+$", os_name)
|
m = re.match(r"^[^ ]+$", os_name)
|
||||||
self.assertIsNotNone(m)
|
self.assertIsNotNone(m)
|
||||||
|
|
||||||
|
@pytest.mark.skip_cq("TODO(b/266734831): Find out why this fails in CQ")
|
||||||
def test_smoke_repo(self):
|
def test_smoke_repo(self):
|
||||||
"""Make sure repo UA returns something useful."""
|
"""Make sure repo UA returns something useful."""
|
||||||
ua = git_command.user_agent.repo
|
ua = git_command.user_agent.repo
|
||||||
@ -271,6 +274,7 @@ class UserAgentUnitTest(unittest.TestCase):
|
|||||||
m = re.match(r"^git-repo/[^ ]+ ([^ ]+) git/[^ ]+ Python/[0-9.]+", ua)
|
m = re.match(r"^git-repo/[^ ]+ ([^ ]+) git/[^ ]+ Python/[0-9.]+", ua)
|
||||||
self.assertIsNotNone(m)
|
self.assertIsNotNone(m)
|
||||||
|
|
||||||
|
@pytest.mark.skip_cq("TODO(b/266734831): Find out why this fails in CQ")
|
||||||
def test_smoke_git(self):
|
def test_smoke_git(self):
|
||||||
"""Make sure git UA returns something useful."""
|
"""Make sure git UA returns something useful."""
|
||||||
ua = git_command.user_agent.git
|
ua = git_command.user_agent.git
|
||||||
|
@ -21,6 +21,7 @@ import tempfile
|
|||||||
import unittest
|
import unittest
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
|
import pytest
|
||||||
from test_manifest_xml import sort_attributes
|
from test_manifest_xml import sort_attributes
|
||||||
|
|
||||||
import git_superproject
|
import git_superproject
|
||||||
@ -145,6 +146,7 @@ class SuperprojectTestCase(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
self.assertIsNone(manifest.superproject)
|
self.assertIsNone(manifest.superproject)
|
||||||
|
|
||||||
|
@pytest.mark.skip_cq("TODO(b/266734831): Find out why this takes 8m+ in CQ")
|
||||||
def test_superproject_get_superproject_invalid_url(self):
|
def test_superproject_get_superproject_invalid_url(self):
|
||||||
"""Test with an invalid url."""
|
"""Test with an invalid url."""
|
||||||
manifest = self.getXmlManifest(
|
manifest = self.getXmlManifest(
|
||||||
@ -168,6 +170,7 @@ class SuperprojectTestCase(unittest.TestCase):
|
|||||||
self.assertFalse(sync_result.success)
|
self.assertFalse(sync_result.success)
|
||||||
self.assertTrue(sync_result.fatal)
|
self.assertTrue(sync_result.fatal)
|
||||||
|
|
||||||
|
@pytest.mark.skip_cq("TODO(b/266734831): Find out why this takes 8m+ in CQ")
|
||||||
def test_superproject_get_superproject_invalid_branch(self):
|
def test_superproject_get_superproject_invalid_branch(self):
|
||||||
"""Test with an invalid branch."""
|
"""Test with an invalid branch."""
|
||||||
manifest = self.getXmlManifest(
|
manifest = self.getXmlManifest(
|
||||||
|
Reference in New Issue
Block a user