gw: add skipping test suites
This commit is contained in:
parent
942dba8ea3
commit
627550840c
@ -30,7 +30,7 @@ from liteeth.phy.ecp5rgmii import LiteEthPHYRGMII
|
|||||||
from sampler import Sampler
|
from sampler import Sampler
|
||||||
from litex.soc.integration.soc import SoCRegion
|
from litex.soc.integration.soc import SoCRegion
|
||||||
|
|
||||||
from test import run_test, TestResult
|
from test import run_test, TestResult, skip_suite
|
||||||
|
|
||||||
# CRG ----------------------------------------------------------------------------------------------
|
# CRG ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
Helper functions for a basic test suite
|
Helper functions for a basic test suite
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import Callable
|
from typing import Callable, List
|
||||||
from enum import StrEnum
|
from enum import StrEnum
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
@ -25,15 +25,21 @@ class TestInfo:
|
|||||||
return f"[{self.suite_name}.{self.test_name}] {self.result}"
|
return f"[{self.suite_name}.{self.test_name}] {self.result}"
|
||||||
|
|
||||||
|
|
||||||
|
skipped_suites: List[str] = []
|
||||||
|
|
||||||
|
|
||||||
|
def skip_suite(suite_name: str):
|
||||||
|
"""Skips running tests from a specific suite"""
|
||||||
|
skipped_suites.append(suite_name)
|
||||||
|
|
||||||
|
|
||||||
def run_test(suite_name: str, test_fn: Callable, do_skip = False) -> TestResult:
|
def run_test(suite_name: str, test_fn: Callable, do_skip = False) -> TestResult:
|
||||||
test_name = test_fn.__name__
|
test_name = test_fn.__name__
|
||||||
|
|
||||||
print(f"[{suite_name}.{test_name}] Running...")
|
if do_skip or suite_name in skipped_suites:
|
||||||
|
|
||||||
if do_skip:
|
|
||||||
res = TestInfo(suite_name, test_name, TestResult.SKIP)
|
res = TestInfo(suite_name, test_name, TestResult.SKIP)
|
||||||
else:
|
else:
|
||||||
|
print(f"[{suite_name}.{test_name}] Running...")
|
||||||
try:
|
try:
|
||||||
test_fn()
|
test_fn()
|
||||||
res = TestInfo(suite_name, test_name, TestResult.PASS)
|
res = TestInfo(suite_name, test_name, TestResult.PASS)
|
||||||
@ -41,7 +47,5 @@ def run_test(suite_name: str, test_fn: Callable, do_skip = False) -> TestResult:
|
|||||||
res = TestInfo(suite_name, test_name, TestResult.FAIL)
|
res = TestInfo(suite_name, test_name, TestResult.FAIL)
|
||||||
print_exc()
|
print_exc()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print(res)
|
print(res)
|
||||||
return res
|
return res
|
||||||
|
Loading…
Reference in New Issue
Block a user