@@ -117,6 +117,7 @@ class RequestedState(Enum):
117
117
Next = 2
118
118
StepIn = 3
119
119
StepOut = 4
120
+ Running = 5
120
121
121
122
122
123
class BreakpointsEntry (NamedTuple ):
@@ -338,25 +339,16 @@ def stop(self) -> None:
338
339
339
340
self .condition .notify_all ()
340
341
341
- def continue_all (self , send_event : bool = True ) -> None :
342
+ def continue_all (self ) -> None :
342
343
if self .main_thread is not None and self .main_thread .ident is not None :
343
- self .continue_thread (self .main_thread .ident , send_event )
344
+ self .continue_thread (self .main_thread .ident )
344
345
345
- def continue_thread (self , thread_id : int , send_event : bool = False ) -> None :
346
+ def continue_thread (self , thread_id : int ) -> None :
346
347
if self .main_thread is None or thread_id != self .main_thread .ident :
347
348
raise InvalidThreadIdError (thread_id )
348
349
349
350
with self .condition :
350
- if send_event :
351
- self .send_event (
352
- self ,
353
- ContinuedEvent (
354
- body = ContinuedEventBody (thread_id = self .main_thread .ident , all_threads_continued = True )
355
- ),
356
- )
357
-
358
- self .requested_state = RequestedState .Nothing
359
- self .state = State .Running
351
+ self .requested_state = RequestedState .Running
360
352
self .condition .notify_all ()
361
353
362
354
def pause_thread (self , thread_id : int ) -> None :
@@ -365,7 +357,6 @@ def pause_thread(self, thread_id: int) -> None:
365
357
366
358
with self .condition :
367
359
self .requested_state = RequestedState .Pause
368
- self .state = State .Paused
369
360
370
361
self .condition .notify_all ()
371
362
@@ -374,8 +365,6 @@ def next(self, thread_id: int, granularity: Optional[SteppingGranularity] = None
374
365
raise InvalidThreadIdError (thread_id )
375
366
376
367
with self .condition :
377
- self .state = State .Running
378
-
379
368
if self .full_stack_frames and self .full_stack_frames [0 ].type in ["TEST" , "SUITE" ]:
380
369
self .requested_state = RequestedState .StepIn
381
370
else :
@@ -406,7 +395,6 @@ def step_in(
406
395
407
396
with self .condition :
408
397
self .requested_state = RequestedState .StepIn
409
- self .state = State .Running
410
398
411
399
self .condition .notify_all ()
412
400
@@ -416,7 +404,6 @@ def step_out(self, thread_id: int, granularity: Optional[SteppingGranularity] =
416
404
417
405
with self .condition :
418
406
self .requested_state = RequestedState .StepOut
419
- self .state = State .Running
420
407
self .stop_stack_len = len (self .full_stack_frames ) - 1
421
408
422
409
i = 1
@@ -474,7 +461,9 @@ def process_start_state(self, source: str, line_no: int, type: str, status: str)
474
461
return
475
462
476
463
if self .requested_state == RequestedState .Pause :
464
+ self .requested_state = RequestedState .Nothing
477
465
self .state = State .Paused
466
+
478
467
self .send_event (
479
468
self ,
480
469
StoppedEvent (
@@ -484,10 +473,12 @@ def process_start_state(self, source: str, line_no: int, type: str, status: str)
484
473
)
485
474
),
486
475
)
487
- self . requested_state = RequestedState . Nothing
476
+
488
477
elif self .requested_state == RequestedState .Next :
489
478
if len (self .full_stack_frames ) <= self .stop_stack_len :
490
479
self .state = State .Paused
480
+ self .requested_state = RequestedState .Nothing
481
+
491
482
self .send_event (
492
483
self ,
493
484
StoppedEvent (
@@ -497,9 +488,11 @@ def process_start_state(self, source: str, line_no: int, type: str, status: str)
497
488
)
498
489
),
499
490
)
500
- self . requested_state = RequestedState . Nothing
491
+
501
492
elif self .requested_state == RequestedState .StepIn :
502
493
self .state = State .Paused
494
+ self .requested_state = RequestedState .Nothing
495
+
503
496
self .send_event (
504
497
self ,
505
498
StoppedEvent (
@@ -509,9 +502,11 @@ def process_start_state(self, source: str, line_no: int, type: str, status: str)
509
502
)
510
503
),
511
504
)
512
- self . requested_state = RequestedState . Nothing
505
+
513
506
elif self .requested_state == RequestedState .StepOut and len (self .full_stack_frames ) <= self .stop_stack_len :
514
507
self .state = State .Paused
508
+ self .requested_state = RequestedState .Nothing
509
+
515
510
self .send_event (
516
511
self ,
517
512
StoppedEvent (
@@ -521,7 +516,6 @@ def process_start_state(self, source: str, line_no: int, type: str, status: str)
521
516
)
522
517
),
523
518
)
524
- self .requested_state = RequestedState .Nothing
525
519
526
520
if source is not None :
527
521
source_path = self .map_path_to_client (str (Path (source ).absolute ()))
@@ -576,8 +570,9 @@ def process_start_state(self, source: str, line_no: int, type: str, status: str)
576
570
)
577
571
return
578
572
579
- self .requested_state = RequestedState .Nothing
580
573
self .state = State .Paused
574
+ self .requested_state = RequestedState .Nothing
575
+
581
576
self .send_event (
582
577
self ,
583
578
StoppedEvent (
@@ -590,6 +585,52 @@ def process_start_state(self, source: str, line_no: int, type: str, status: str)
590
585
)
591
586
592
587
def process_end_state (self , status : str , filter_id : Set [str ], description : str , text : Optional [str ]) -> None :
588
+ if self .state == State .Stopped :
589
+ return
590
+
591
+ if self .requested_state == RequestedState .Next :
592
+ if len (self .full_stack_frames ) <= self .stop_stack_len :
593
+ self .state = State .Paused
594
+ self .requested_state = RequestedState .Nothing
595
+
596
+ self .send_event (
597
+ self ,
598
+ StoppedEvent (
599
+ body = StoppedEventBody (
600
+ reason = StoppedReason .STEP ,
601
+ thread_id = threading .current_thread ().ident ,
602
+ )
603
+ ),
604
+ )
605
+
606
+ elif self .requested_state == RequestedState .StepIn :
607
+ self .state = State .Paused
608
+ self .requested_state = RequestedState .Nothing
609
+
610
+ self .send_event (
611
+ self ,
612
+ StoppedEvent (
613
+ body = StoppedEventBody (
614
+ reason = StoppedReason .STEP ,
615
+ thread_id = threading .current_thread ().ident ,
616
+ )
617
+ ),
618
+ )
619
+
620
+ elif self .requested_state == RequestedState .StepOut and len (self .full_stack_frames ) <= self .stop_stack_len :
621
+ self .state = State .Paused
622
+ self .requested_state = RequestedState .Nothing
623
+
624
+ self .send_event (
625
+ self ,
626
+ StoppedEvent (
627
+ body = StoppedEventBody (
628
+ reason = StoppedReason .STEP ,
629
+ thread_id = threading .current_thread ().ident ,
630
+ )
631
+ ),
632
+ )
633
+
593
634
if (
594
635
not self .terminated
595
636
and status == "FAIL"
@@ -599,17 +640,18 @@ def process_end_state(self, status: str, filter_id: Set[str], description: str,
599
640
if v .filter_options and any (o for o in v .filter_options if o .filter_id in filter_id )
600
641
)
601
642
):
602
- self .requested_state = RequestedState .Nothing
643
+ reason = StoppedReason .EXCEPTION
644
+
603
645
self .state = State .Paused
646
+ self .requested_state = RequestedState .Nothing
604
647
605
648
self .send_event (
606
649
self ,
607
650
StoppedEvent (
608
651
body = StoppedEventBody (
609
- description = description ,
610
- reason = StoppedReason .EXCEPTION ,
652
+ reason = reason ,
611
653
thread_id = threading .current_thread ().ident ,
612
- all_threads_stopped = True ,
654
+ description = description ,
613
655
text = text ,
614
656
)
615
657
),
@@ -619,7 +661,10 @@ def wait_for_running(self) -> None:
619
661
if self .attached :
620
662
while True :
621
663
with self .condition :
622
- self .condition .wait_for (lambda : self .state in [State .Running , State .Stopped , State .CallKeyword ])
664
+ self .condition .wait_for (
665
+ lambda : self .state in [State .Running , State .Stopped , State .CallKeyword ]
666
+ or self .requested_state != RequestedState .Nothing
667
+ )
623
668
624
669
if self .state == State .CallKeyword :
625
670
self ._evaluated_keyword_result = None
@@ -637,6 +682,18 @@ def wait_for_running(self) -> None:
637
682
638
683
continue
639
684
685
+ if self .requested_state == RequestedState .Running :
686
+ self .state = State .Running
687
+ if self .main_thread is not None and self .main_thread .ident is not None :
688
+ self .send_event (
689
+ self ,
690
+ ContinuedEvent (
691
+ body = ContinuedEventBody (thread_id = self .main_thread .ident , all_threads_continued = True )
692
+ ),
693
+ )
694
+ self .requested_state = RequestedState .Nothing
695
+ continue
696
+
640
697
break
641
698
642
699
def start_output_group (self , name : str , attributes : Dict [str , Any ], type : Optional [str ] = None ) -> None :
@@ -769,6 +826,7 @@ def start_suite(self, name: str, attributes: Dict[str, Any]) -> None:
769
826
if self .stop_on_entry :
770
827
self .stop_on_entry = False
771
828
829
+ self .requested_state = RequestedState .Nothing
772
830
self .state = State .Paused
773
831
self .send_event (
774
832
self ,
0 commit comments