Skip to content

Commit

Permalink
tests: add include and exclude lists for extra tests loader
Browse files Browse the repository at this point in the history
'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)
  • Loading branch information
marmarek committed Nov 30, 2019
1 parent fd8e89c commit 7c18b18
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions qubes/tests/extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#

import asyncio
import os
import subprocess
import sys

Expand Down Expand Up @@ -195,7 +196,18 @@ def add_remove_rule(add=True):


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([
Expand All @@ -210,6 +222,10 @@ def runTest(self):

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(
Expand Down

0 comments on commit 7c18b18

Please sign in to comment.