tests: add include and exclude lists for extra tests loader

'extra' tests run is getting ridiculously long. Allow splitting it into
several jobs. Since this appears as just one class from the test loader
perspective, implement it as environment variables:
 - QUBES_TEST_EXTRA_INCLUDE - load just selected tests
 - QUBES_TEST_EXTRA_EXCLUDE - skip selected tests (to select "the rest"
   tests)
This commit is contained in:
Marek Marczykowski-Górecki 2019-11-30 04:35:18 +01:00
parent fd8e89c546
commit 7c18b187de
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -19,6 +19,7 @@
#
import asyncio
import os
import subprocess
import sys
@ -195,7 +196,18 @@ class ExtraTestCase(qubes.tests.SystemTestCase):
def load_tests(loader, tests, pattern):
include_list = None
if 'QUBES_TEST_EXTRA_INCLUDE' in os.environ:
include_list = os.environ['QUBES_TEST_EXTRA_INCLUDE'].split()
exclude_list = []
if 'QUBES_TEST_EXTRA_EXCLUDE' in os.environ:
exclude_list = os.environ['QUBES_TEST_EXTRA_EXCLUDE'].split()
for entry in pkg_resources.iter_entry_points('qubes.tests.extra'):
if include_list is not None and entry.name not in include_list:
continue
if entry.name in exclude_list:
continue
try:
for test_case in entry.load()():
tests.addTests(loader.loadTestsFromNames([
@ -210,6 +222,10 @@ def load_tests(loader, tests, pattern):
for entry in pkg_resources.iter_entry_points(
'qubes.tests.extra.for_template'):
if include_list is not None and entry.name not in include_list:
continue
if entry.name in exclude_list:
continue
try:
for test_case in entry.load()():
tests.addTests(loader.loadTestsFromNames(