Allow running system tests by mask.

E.g. system/run.py 'ListSnapshot*'.
This commit is contained in:
Andrey Smirnov
2014-07-07 23:13:49 +04:00
parent b75b4d1488
commit d9b35cea01
+27 -7
View File
@@ -4,6 +4,7 @@ import glob
import importlib import importlib
import os import os
import inspect import inspect
import fnmatch
import sys import sys
from lib import BaseTest from lib import BaseTest
@@ -15,11 +16,11 @@ except ImportError:
return s return s
def run(include_long_tests=False, tests=None): def run(include_long_tests=False, tests=None, filters=None):
""" """
Run system test. Run system test.
""" """
if tests is None: if not tests:
tests = glob.glob("t*_*") tests = glob.glob("t*_*")
fails = [] fails = []
numTests = numFailed = numSkipped = 0 numTests = numFailed = numSkipped = 0
@@ -34,6 +35,17 @@ def run(include_long_tests=False, tests=None):
if not (inspect.isclass(o) and issubclass(o, BaseTest) and o is not BaseTest): if not (inspect.isclass(o) and issubclass(o, BaseTest) and o is not BaseTest):
continue continue
if filters:
matches = False
for filt in filters:
if fnmatch.fnmatch(o.__name__, filt):
matches = True
break
if not matches:
continue
t = o() t = o()
if t.longTest and not include_long_tests or not t.fixture_available(): if t.longTest and not include_long_tests or not t.fixture_available():
numSkipped += 1 numSkipped += 1
@@ -70,10 +82,18 @@ if __name__ == "__main__":
os.chdir(os.path.realpath(os.path.dirname(sys.argv[0]))) os.chdir(os.path.realpath(os.path.dirname(sys.argv[0])))
include_long_tests = False include_long_tests = False
tests = None tests = None
if len(sys.argv) > 1: args = sys.argv[1:]
if sys.argv[1] == "--long": if len(args) > 0 and args[0] == "--long":
include_long_tests = True include_long_tests = True
tests = sys.argv[2:] args = args[1:]
tests = []
filters = []
for arg in args:
if arg.startswith('t'):
tests.append(arg)
else: else:
tests = sys.argv[1:] filters.append(arg)
run(include_long_tests, tests)
run(include_long_tests, tests, filters)