mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-devtest
synced 2026-01-15 10:23:32 +01:00
Add support for test-os --cases option
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
765e6f3a1b
commit
142c1dbf6d
2 changed files with 16 additions and 2 deletions
|
|
@ -82,7 +82,8 @@ class CmdTestOs(MachineCmd): # export
|
||||||
machine = None
|
machine = None
|
||||||
try:
|
try:
|
||||||
machine = await Machine.create(env)
|
machine = await Machine.create(env)
|
||||||
test_cases = TestCases(env.args.test_case_path, dummies=env.args.dummy_tests)
|
case_filter = None if not env.args.cases else env.args.cases.split(',')
|
||||||
|
test_cases = TestCases(env.args.test_case_path, include=case_filter, dummies=env.args.dummy_tests)
|
||||||
for phase in TestPhases.Phase:
|
for phase in TestPhases.Phase:
|
||||||
if not machine.clear_for_tests():
|
if not machine.clear_for_tests():
|
||||||
raise Exception("machine is not clear for running tests")
|
raise Exception("machine is not clear for running tests")
|
||||||
|
|
@ -123,5 +124,6 @@ class CmdTestOs(MachineCmd): # export
|
||||||
|
|
||||||
def add_parser(self, parsers):
|
def add_parser(self, parsers):
|
||||||
p = super().add_parser(parsers)
|
p = super().add_parser(parsers)
|
||||||
|
p.add_argument( "--cases", help="List of dedicated test cases to run, wildcards are supported", default='')
|
||||||
self.__results.add_arguments(p)
|
self.__results.add_arguments(p)
|
||||||
return p
|
return p
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ from abc import abstractmethod, ABC
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import inspect
|
import inspect
|
||||||
|
import fnmatch
|
||||||
from jwutils.log import *
|
from jwutils.log import *
|
||||||
from jwutils.misc import *
|
from jwutils.misc import *
|
||||||
from .TestCase import TestCase
|
from .TestCase import TestCase
|
||||||
|
|
@ -12,12 +13,21 @@ from .tcf import *
|
||||||
|
|
||||||
class TestCases: # export
|
class TestCases: # export
|
||||||
|
|
||||||
def __init__(self, path, dummies=False):
|
def __match(self, case):
|
||||||
|
if self.__include is None:
|
||||||
|
return True
|
||||||
|
for pattern in self.__include:
|
||||||
|
if fnmatch.fnmatch(case.name, pattern):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def __init__(self, path, include=None, dummies=False):
|
||||||
|
|
||||||
self.__path = path.split(':')
|
self.__path = path.split(':')
|
||||||
self.__dummies = dummies
|
self.__dummies = dummies
|
||||||
self.__idx = 0
|
self.__idx = 0
|
||||||
self.__cases = []
|
self.__cases = []
|
||||||
|
self.__include = [include] if isinstance(include, str) else include
|
||||||
factories = set()
|
factories = set()
|
||||||
# use list() to avoid expansion of sys.modules during iteration
|
# use list() to avoid expansion of sys.modules during iteration
|
||||||
for name, mod in list(sys.modules.items()):
|
for name, mod in list(sys.modules.items()):
|
||||||
|
|
@ -35,6 +45,8 @@ class TestCases: # export
|
||||||
for c in cases:
|
for c in cases:
|
||||||
if c.is_dummy and not self.__dummies:
|
if c.is_dummy and not self.__dummies:
|
||||||
continue
|
continue
|
||||||
|
if not self.__match(c):
|
||||||
|
continue
|
||||||
c.factory = factory
|
c.factory = factory
|
||||||
self.__cases.append(c)
|
self.__cases.append(c)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue