Explorar el Código

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)
Marek Marczykowski-Górecki hace 4 años
padre
commit
7c18b187de
Se han modificado 1 ficheros con 16 adiciones y 0 borrados
  1. 16 0
      qubes/tests/extra.py

+ 16 - 0
qubes/tests/extra.py

@@ -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(