update test cases for twister 1. test_errors.py add protection. 2. test_handlers.py change call to status 3. test_testsuite.py change call to status The log traces for TwisterException objects only. And the stack trace output follow the same rules for all exceptions, but StatusAttributeError with its dedicated handlers. Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
32 lines
960 B
Python
32 lines
960 B
Python
# vim: set syntax=python ts=4 :
|
|
#
|
|
# Copyright (c) 2018-2022 Intel Corporation
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
import logging
|
|
import traceback
|
|
|
|
logger = logging.getLogger('twister')
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
class TwisterException(Exception):
|
|
def __init__(self, message="TwisterException"):
|
|
super().__init__(message)
|
|
logger.error(''.join(["Twister call stack dump:\n"] + traceback.format_stack()[:-1]))
|
|
|
|
class TwisterRuntimeError(TwisterException):
|
|
pass
|
|
|
|
class ConfigurationError(TwisterException):
|
|
def __init__(self, cfile, message):
|
|
TwisterException.__init__(self, str(cfile) + ": " + message)
|
|
|
|
class BuildError(TwisterException):
|
|
pass
|
|
|
|
class ExecutionError(TwisterException):
|
|
pass
|
|
|
|
class StatusAttributeError(TwisterException):
|
|
def __init__(self, cls : type, value):
|
|
msg = f'{cls.__name__} assigned status {value}, which could not be cast to a TwisterStatus.'
|
|
super().__init__(msg)
|