2024-04-11 16:53:40 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# Copyright (c) 2024 Intel Corporation
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
"""
|
|
|
|
Status classes to be used instead of str statuses.
|
|
|
|
"""
|
2024-09-12 21:20:12 +08:00
|
|
|
from __future__ import annotations
|
2024-04-11 16:53:40 +08:00
|
|
|
|
2024-09-12 21:20:12 +08:00
|
|
|
from colorama import Fore
|
2024-04-11 16:53:40 +08:00
|
|
|
from enum import Enum
|
|
|
|
|
|
|
|
|
2024-05-28 20:31:53 +08:00
|
|
|
class TwisterStatus(str, Enum):
|
2024-04-11 16:53:40 +08:00
|
|
|
def __str__(self):
|
|
|
|
return str(self.value)
|
|
|
|
|
2024-09-12 19:01:10 +08:00
|
|
|
@classmethod
|
|
|
|
def _missing_(cls, value):
|
|
|
|
super()._missing_(value)
|
|
|
|
if value is None:
|
|
|
|
return TwisterStatus.NONE
|
|
|
|
|
2024-09-12 21:20:12 +08:00
|
|
|
@staticmethod
|
|
|
|
def get_color(status: TwisterStatus) -> str:
|
2024-09-19 00:58:31 +08:00
|
|
|
status2color = {
|
|
|
|
TwisterStatus.PASS: Fore.GREEN,
|
|
|
|
TwisterStatus.SKIP: Fore.YELLOW,
|
|
|
|
TwisterStatus.FILTER: Fore.YELLOW,
|
|
|
|
TwisterStatus.BLOCK: Fore.YELLOW,
|
|
|
|
TwisterStatus.FAIL: Fore.RED,
|
|
|
|
TwisterStatus.ERROR: Fore.RED,
|
|
|
|
TwisterStatus.STARTED: Fore.MAGENTA,
|
|
|
|
TwisterStatus.NONE: Fore.MAGENTA
|
|
|
|
}
|
|
|
|
return status2color[status] if status in status2color else Fore.RESET
|
2024-09-12 21:20:12 +08:00
|
|
|
|
2024-05-28 20:31:53 +08:00
|
|
|
# All statuses below this comment can be used for TestCase
|
2024-04-11 16:53:40 +08:00
|
|
|
BLOCK = 'blocked'
|
|
|
|
STARTED = 'started'
|
|
|
|
|
2024-05-28 20:31:53 +08:00
|
|
|
# All statuses below this comment can be used for TestSuite
|
|
|
|
# All statuses below this comment can be used for TestInstance
|
|
|
|
FILTER = 'filtered'
|
2024-04-11 16:53:40 +08:00
|
|
|
|
2024-05-28 20:31:53 +08:00
|
|
|
# All statuses below this comment can be used for Harness
|
|
|
|
NONE = None
|
2024-04-11 16:53:40 +08:00
|
|
|
ERROR = 'error'
|
|
|
|
FAIL = 'failed'
|
|
|
|
PASS = 'passed'
|
|
|
|
SKIP = 'skipped'
|