зеркало из https://github.com/microsoft/lisa.git
Support skip run on unfit environment
This commit is contained in:
Родитель
0c7a5a5dbe
Коммит
3b8ff9b06d
|
@ -12,6 +12,11 @@ from lisa.tool import Ntttcp
|
|||
tags=["demo"],
|
||||
)
|
||||
class WithScript(TestSuite):
|
||||
@property
|
||||
def skipRun(self) -> bool:
|
||||
node = self.environment.defaultNode
|
||||
return not node.isLinux
|
||||
|
||||
@CaseMetadata(
|
||||
description="""
|
||||
this test case run script on test node.
|
||||
|
|
|
@ -31,8 +31,11 @@ class SuiteMetadata:
|
|||
)
|
||||
|
||||
def wrapper(
|
||||
test_class: Type[TestSuite], environment: Environment, cases: List[str]
|
||||
test_class: Type[TestSuite],
|
||||
environment: Environment,
|
||||
cases: List[str],
|
||||
metadata: SuiteMetadata,
|
||||
) -> TestSuite:
|
||||
return test_class(environment, cases)
|
||||
return test_class(environment, cases, metadata)
|
||||
|
||||
return wrapper
|
||||
|
|
|
@ -8,15 +8,24 @@ from lisa.core.actionStatus import ActionStatus
|
|||
from lisa.util.logger import log
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from lisa import SuiteMetadata
|
||||
|
||||
from .environment import Environment
|
||||
|
||||
|
||||
class TestSuite(Action, metaclass=ABCMeta):
|
||||
def __init__(self, environment: Environment, cases: List[str]) -> None:
|
||||
def __init__(
|
||||
self, environment: Environment, cases: List[str], suiteMetadata: SuiteMetadata
|
||||
) -> None:
|
||||
self.environment = environment
|
||||
self.cases = cases
|
||||
self.suiteMetadata = suiteMetadata
|
||||
self.shouldStop = False
|
||||
|
||||
@property
|
||||
def skipRun(self) -> bool:
|
||||
return False
|
||||
|
||||
def beforeSuite(self) -> None:
|
||||
pass
|
||||
|
||||
|
@ -33,6 +42,9 @@ class TestSuite(Action, metaclass=ABCMeta):
|
|||
return "TestSuite"
|
||||
|
||||
async def start(self) -> None:
|
||||
if self.skipRun:
|
||||
log.info(f"suite[{self.suiteMetadata.name}] skipped on this run")
|
||||
return
|
||||
self.beforeSuite()
|
||||
for test_case in self.cases:
|
||||
self.beforeCase()
|
||||
|
|
|
@ -37,7 +37,7 @@ class LISARunner(TestRunner):
|
|||
|
||||
for suite in suites.values():
|
||||
test_object: TestSuite = suite.test_class(
|
||||
environment, list(suite.cases.keys())
|
||||
environment, list(suite.cases.keys()), suite
|
||||
)
|
||||
await test_object.start()
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче