@@ -184,6 +184,11 @@ def __init__(self) -> None:
184184 self .hit_counts : Dict [HitCountEntry , int ] = {}
185185 self .last_fail_message : Optional [str ] = None
186186 self .stop_on_entry = False
187+ self .no_debug = False
188+
189+ @property
190+ def debug (self ) -> bool :
191+ return not self .no_debug
187192
188193 @property
189194 def robot_report_file (self ) -> Optional [str ]:
@@ -549,35 +554,37 @@ def start_suite(self, name: str, attributes: Dict[str, Any]) -> None:
549554
550555 entry = self .add_stackframe_entry (longname , type , source , line_no )
551556
552- if self .stop_on_entry :
553- self .stop_on_entry = False
557+ if self .debug :
558+ if self .stop_on_entry :
559+ self .stop_on_entry = False
554560
555- self .state = State .Paused
556- self .send_event (
557- self ,
558- StoppedEvent (
559- body = StoppedEventBody (
560- reason = StoppedReason .ENTRY ,
561- thread_id = threading .current_thread ().ident ,
562- )
563- ),
564- )
561+ self .state = State .Paused
562+ self .send_event (
563+ self ,
564+ StoppedEvent (
565+ body = StoppedEventBody (
566+ reason = StoppedReason .ENTRY ,
567+ thread_id = threading .current_thread ().ident ,
568+ )
569+ ),
570+ )
565571
566- self .wait_for_running ()
567- elif entry .source :
568- self .process_start_state (entry .source , entry .line , entry .type , status )
572+ self .wait_for_running ()
573+ elif entry .source :
574+ self .process_start_state (entry .source , entry .line , entry .type , status )
569575
570- self .wait_for_running ()
576+ self .wait_for_running ()
571577
572578 def end_suite (self , name : str , attributes : Dict [str , Any ]) -> None :
573- status = attributes .get ("status" , "" )
574-
575- self .process_end_state (
576- status ,
577- "failed_suite" ,
578- "Suite failed." ,
579- f"Suite failed{ f': { v } ' if (v := attributes .get ('message' , None )) else '' } " ,
580- )
579+ if self .debug :
580+ status = attributes .get ("status" , "" )
581+
582+ self .process_end_state (
583+ status ,
584+ "failed_suite" ,
585+ "Suite failed." ,
586+ f"Suite failed{ f': { v } ' if (v := attributes .get ('message' , None )) else '' } " ,
587+ )
581588
582589 if self .stack_frames :
583590 self .stack_frames .popleft ()
@@ -592,20 +599,22 @@ def start_test(self, name: str, attributes: Dict[str, Any]) -> None:
592599
593600 entry = self .add_stackframe_entry (longname , type , source , line_no )
594601
595- if entry .source :
596- self .process_start_state (entry .source , entry .line , entry .type , status )
602+ if self .debug :
603+ if entry .source :
604+ self .process_start_state (entry .source , entry .line , entry .type , status )
597605
598- self .wait_for_running ()
606+ self .wait_for_running ()
599607
600608 def end_test (self , name : str , attributes : Dict [str , Any ]) -> None :
601- status = attributes .get ("status" , "" )
602-
603- self .process_end_state (
604- status ,
605- "failed_test" ,
606- "Test failed." ,
607- f"Test failed{ f': { v } ' if (v := attributes .get ('message' , None )) else '' } " ,
608- )
609+ if self .debug :
610+ status = attributes .get ("status" , "" )
611+
612+ self .process_end_state (
613+ status ,
614+ "failed_test" ,
615+ "Test failed." ,
616+ f"Test failed{ f': { v } ' if (v := attributes .get ('message' , None )) else '' } " ,
617+ )
609618
610619 if self .stack_frames :
611620 self .stack_frames .popleft ()
@@ -623,18 +632,20 @@ def start_keyword(self, name: str, attributes: Dict[str, Any]) -> None:
623632
624633 entry = self .add_stackframe_entry (kwname , type , source , line_no )
625634
626- if entry .source :
627- self .process_start_state (entry .source , entry .line , entry .type , status )
635+ if self .debug :
636+ if entry .source :
637+ self .process_start_state (entry .source , entry .line , entry .type , status )
628638
629- self .wait_for_running ()
639+ self .wait_for_running ()
630640
631641 def end_keyword (self , name : str , attributes : Dict [str , Any ]) -> None :
632- status = attributes .get ("status" , "" )
642+ if self .debug :
643+ status = attributes .get ("status" , "" )
633644
634- if status = = "NOT RUN" :
635- return
636-
637- self . process_end_state ( status , "failed_keyword" , "Keyword failed." , f"Keyword failed: { self . last_fail_message } " )
645+ if status ! = "NOT RUN" :
646+ self . process_end_state (
647+ status , "failed_keyword" , "Keyword failed." , f"Keyword failed: { self . last_fail_message } "
648+ )
638649
639650 if self .stack_frames :
640651 self .stack_frames .popleft ()
@@ -674,12 +685,20 @@ def log_message(self, message: Dict[str, Any]) -> None:
674685 if message ["level" ] == "FAIL" :
675686 self .last_fail_message = message ["message" ]
676687
688+ current_frame = self .stack_frames [- 1 ] if self .stack_frames else None
689+ source = Source (path = current_frame .source ) if current_frame else None
690+ line = current_frame .line - 1 if current_frame else None
691+
677692 if self .output_log :
678693 self .send_event (
679694 self ,
680695 OutputEvent (
681696 body = OutputEventBody (
682- output = "LOG> {timestamp} {level}: {message}\n " .format (** message ), category = "log"
697+ output = "LOG> {timestamp} {level}: {message}\n " .format (** message ),
698+ category = "log" ,
699+ source = source ,
700+ line = line ,
701+ column = 0 if source is not None else None ,
683702 )
684703 ),
685704 )
0 commit comments