Skip to content

Commit

Permalink
fix(debugger): corrected evaluating/executing keywords for RF 7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
d-biehl committed Jan 22, 2025
1 parent d9ca3b6 commit df92ad4
Showing 1 changed file with 48 additions and 12 deletions.
60 changes: 48 additions & 12 deletions packages/debugger/src/robotcode/debugger/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,9 @@ def set_breakpoints(
return []

def process_start_state(self, source: str, line_no: int, type: str, status: str) -> None:
if self.state == State.CallKeyword:
return

if self.state == State.Stopped:
return

Expand Down Expand Up @@ -718,6 +721,8 @@ def process_end_state(
description: str,
text: Optional[str],
) -> None:
if self.state == State.CallKeyword:
return
if self.state == State.Stopped:
return

Expand Down Expand Up @@ -911,6 +916,9 @@ def remove_stackframe_entry(
self.stack_frames[0].stack_frames.popleft()

def start_suite(self, name: str, attributes: Dict[str, Any]) -> None:
if self.state == State.CallKeyword:
return

if not self.run_started:
self.run_started = True
self.debug_logger = DebugLogger()
Expand Down Expand Up @@ -956,6 +964,9 @@ def start_suite(self, name: str, attributes: Dict[str, Any]) -> None:
self.wait_for_running()

def end_suite(self, name: str, attributes: Dict[str, Any]) -> None:
if self.state == State.CallKeyword:
return

if self.debug:
status = attributes.get("status", "")

Expand All @@ -975,6 +986,9 @@ def end_suite(self, name: str, attributes: Dict[str, Any]) -> None:
self.remove_stackframe_entry(name, type, source, line_no)

def start_test(self, name: str, attributes: Dict[str, Any]) -> None:
if self.state == State.CallKeyword:
return

source = attributes.get("source")
line_no_dummy = attributes.get("lineno", 1)
if isinstance(line_no_dummy, str):
Expand All @@ -999,6 +1013,9 @@ def start_test(self, name: str, attributes: Dict[str, Any]) -> None:
self.wait_for_running()

def end_test(self, name: str, attributes: Dict[str, Any]) -> None:
if self.state == State.CallKeyword:
return

if self.debug:
status = attributes.get("status", "")

Expand Down Expand Up @@ -1030,6 +1047,9 @@ def get_current_keyword_handler(self, name: str) -> UserKeywordHandler:
return EXECUTION_CONTEXTS.current.namespace.get_runner(name)._handler

def start_keyword(self, name: str, attributes: Dict[str, Any]) -> None:
if self.state == State.CallKeyword:
return

status = attributes.get("status", "")
source = attributes.get("source")
line_no_dummy = attributes.get("lineno", 1)
Expand Down Expand Up @@ -1157,6 +1177,9 @@ def is_not_caugthed_by_except(self, message: Optional[str]) -> bool:
return True

def end_keyword(self, name: str, attributes: Dict[str, Any]) -> None:
if self.state == State.CallKeyword:
return

type = attributes.get("type")
if self.debug:
status = attributes.get("status", "")
Expand Down Expand Up @@ -1618,6 +1641,18 @@ def _run_keyword(self, kw: Keyword, context: Any) -> Any:
def _run_keyword(self, kw: Keyword, context: Any) -> Any:
return kw.run(context)

if get_robot_version() >= (7, 2):

@staticmethod
def check_message_is_logged(listener: Any, msg: Any) -> bool:
return cast(bool, listener._is_logged(msg))

else:

@staticmethod
def check_message_is_logged(listener: Any, msg: Any) -> bool:
return cast(bool, listener._is_logged(msg.level))

def evaluate(
self,
expression: str,
Expand Down Expand Up @@ -1745,18 +1780,19 @@ def run_kw() -> Any:
result = e
break
finally:
messages = LOGGER._log_message_cache or []
for msg in messages or ():
# hack to get and evaluate log level
listener: Any = next(iter(LOGGER), None)
if listener is None or listener._is_logged(msg.level):
self.log_message(
{
"level": msg.level,
"message": msg.message,
"timestamp": msg.timestamp,
}
)
if get_robot_version() <= (7, 2):
messages = LOGGER._log_message_cache or []
for msg in messages or ():
# hack to get and evaluate log level
listener: Any = next(iter(LOGGER), None)
if listener is None or self.check_message_is_logged(listener, msg):
self.log_message(
{
"level": msg.level,
"message": msg.message,
"timestamp": msg.timestamp,
}
)
return result

result = self.run_in_robot_thread(run_kw)
Expand Down

0 comments on commit df92ad4

Please sign in to comment.