Skip to content

Commit

Permalink
scripts: twister: Don't use match/case statements
Browse files Browse the repository at this point in the history
Don't use match/case syntax to allow twister to run with
python3 versions < 3.10.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
  • Loading branch information
golowanow authored and fabiobaltieri committed Sep 21, 2024
1 parent 42020f2 commit 4cc3134
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions scripts/pylib/twister/twisterlib/statuses.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,17 @@ def _missing_(cls, value):

@staticmethod
def get_color(status: TwisterStatus) -> str:
match(status):
case TwisterStatus.PASS:
color = Fore.GREEN
case TwisterStatus.SKIP | TwisterStatus.FILTER | TwisterStatus.BLOCK:
color = Fore.YELLOW
case TwisterStatus.FAIL | TwisterStatus.ERROR:
color = Fore.RED
case TwisterStatus.STARTED | TwisterStatus.NONE:
color = Fore.MAGENTA
case _:
color = Fore.RESET
return color
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

# All statuses below this comment can be used for TestCase
BLOCK = 'blocked'
Expand Down

0 comments on commit 4cc3134

Please sign in to comment.