10
10
11
11
from .dap_types import Event , Model
12
12
from .debugger import Debugger
13
+ from .mixins import SyncedEventBody
13
14
14
15
15
16
@dataclass
16
- class RobotExecutionEventBody (Model ):
17
+ class RobotExecutionEventBody (Model , SyncedEventBody ):
17
18
type : str
18
19
id : str
19
20
name : str
20
21
parent_id : Optional [str ] = None
21
22
attributes : Optional [Dict [str , Any ]] = None
22
23
failed_keywords : Optional [List [Dict [str , Any ]]] = None
24
+ source : Optional [str ] = None
25
+ lineno : Optional [int ] = None
26
+ synced : bool = True
27
+
28
+
29
+ @dataclass
30
+ class RobotEnqueuedEventBody (Model , SyncedEventBody ):
31
+ items : List [str ]
32
+ synced : bool = True
33
+
34
+
35
+ @dataclass
36
+ class RobotLogMessageEventBody (Model , SyncedEventBody ):
37
+ item_id : Optional [str ]
38
+
39
+ message : Optional [str ]
40
+ level : Optional [str ]
41
+ timestamp : Optional [str ]
42
+ html : Optional [str ]
43
+
44
+ source : Optional [str ] = None
45
+ lineno : Optional [int ] = None
46
+ column : Optional [int ] = None
47
+
48
+ synced : bool = True
23
49
24
50
25
51
def source_from_attributes (attributes : Dict [str , Any ]) -> str :
@@ -40,6 +66,7 @@ def __init__(self) -> None:
40
66
41
67
def start_suite (self , name : str , attributes : Dict [str , Any ]) -> None :
42
68
id = f"{ source_from_attributes (attributes )} ;{ attributes .get ('longname' , '' )} "
69
+
43
70
Debugger .instance ().send_event (
44
71
self ,
45
72
Event (
@@ -50,6 +77,8 @@ def start_suite(self, name: str, attributes: Dict[str, Any]) -> None:
50
77
id = id ,
51
78
parent_id = self .suite_id_stack [- 1 ] if self .suite_id_stack else None ,
52
79
attributes = dict (attributes ),
80
+ source = source_from_attributes (attributes ) or None ,
81
+ lineno = attributes .get ("lineno" , None ),
53
82
),
54
83
),
55
84
)
@@ -76,6 +105,8 @@ def end_suite(self, name: str, attributes: Dict[str, Any]) -> None:
76
105
id = id ,
77
106
parent_id = self .suite_id_stack [- 1 ] if self .suite_id_stack else None ,
78
107
failed_keywords = self .failed_keywords ,
108
+ source = source_from_attributes (attributes ) or None ,
109
+ lineno = attributes .get ("lineno" , None ),
79
110
),
80
111
),
81
112
)
@@ -96,6 +127,8 @@ def start_test(self, name: str, attributes: Dict[str, Any]) -> None:
96
127
f"{ attributes .get ('lineno' , 0 )} " ,
97
128
parent_id = self .suite_id_stack [- 1 ] if self .suite_id_stack else None ,
98
129
attributes = dict (attributes ),
130
+ source = source_from_attributes (attributes ) or None ,
131
+ lineno = attributes .get ("lineno" , None ),
99
132
),
100
133
),
101
134
)
@@ -121,6 +154,8 @@ def end_test(self, name: str, attributes: Dict[str, Any]) -> None:
121
154
parent_id = self .suite_id_stack [- 1 ] if self .suite_id_stack else None ,
122
155
attributes = dict (attributes ),
123
156
failed_keywords = self .failed_keywords ,
157
+ source = source_from_attributes (attributes ) or None ,
158
+ lineno = attributes .get ("lineno" , None ),
124
159
),
125
160
),
126
161
)
@@ -135,11 +170,45 @@ def start_keyword(self, name: str, attributes: Dict[str, Any]) -> None:
135
170
attributes .get ("type" ),
136
171
)
137
172
173
+ # if Debugger.instance().state != State.CallKeyword:
174
+ # Debugger.instance().send_event(
175
+ # self,
176
+ # Event(
177
+ # event="robotStarted",
178
+ # body=RobotExecutionEventBody(
179
+ # type="keyword",
180
+ # name=name,
181
+ # id=f"{source_from_attributes(attributes)};{name};{attributes.get('lineno', 0)}",
182
+ # parent_id=self.suite_id_stack[-1] if self.suite_id_stack else None,
183
+ # attributes=dict(attributes),
184
+ # source=source_from_attributes(attributes) or None,
185
+ # lineno=attributes.get("lineno", None),
186
+ # ),
187
+ # ),
188
+ # )
189
+
138
190
Debugger .instance ().start_keyword (name , attributes )
139
191
140
192
def end_keyword (self , name : str , attributes : Dict [str , Any ]) -> None :
141
193
Debugger .instance ().end_keyword (name , attributes )
142
194
195
+ # if Debugger.instance().state != State.CallKeyword:
196
+ # Debugger.instance().send_event(
197
+ # self,
198
+ # Event(
199
+ # event="robotEnded",
200
+ # body=RobotExecutionEventBody(
201
+ # type="keyword",
202
+ # name=name,
203
+ # id=f"{source_from_attributes(attributes)};{name};{attributes.get('lineno', 0)}",
204
+ # parent_id=self.suite_id_stack[-1] if self.suite_id_stack else None,
205
+ # attributes=dict(attributes),
206
+ # source=source_from_attributes(attributes) or None,
207
+ # lineno=attributes.get("lineno", None),
208
+ # ),
209
+ # ),
210
+ # )
211
+
143
212
if attributes ["type" ] in ["KEYWORD" , "SETUP" , "TEARDOWN" ]:
144
213
Debugger .instance ().end_output_group (name , attributes , attributes .get ("type" ))
145
214
@@ -189,14 +258,16 @@ def log_message(self, message: Dict[str, Any]) -> None:
189
258
self ,
190
259
Event (
191
260
event = "robotLog" ,
192
- body = {
193
- "itemId" : item_id ,
194
- "source" : source ,
195
- "lineno" : line ,
196
- "column" : column ,
197
- ** dict (message ),
198
- ** ({"message" : msg } if msg else {}),
199
- },
261
+ body = RobotLogMessageEventBody (
262
+ item_id = item_id ,
263
+ message = msg if msg else message .get ("message" , None ),
264
+ level = message .get ("level" , None ),
265
+ timestamp = message .get ("timestamp" , None ),
266
+ html = message .get ("html" , None ),
267
+ source = source ,
268
+ lineno = line ,
269
+ column = column ,
270
+ ),
200
271
),
201
272
)
202
273
@@ -236,14 +307,16 @@ def message(self, message: Dict[str, Any]) -> None:
236
307
self ,
237
308
Event (
238
309
event = "robotMessage" ,
239
- body = {
240
- "itemId" : item_id ,
241
- "source" : source ,
242
- "lineno" : line ,
243
- "column" : column ,
244
- ** dict (message ),
245
- ** ({"message" : msg } if msg else {}),
246
- },
310
+ body = RobotLogMessageEventBody (
311
+ item_id = item_id ,
312
+ message = msg if msg else message .get ("message" , None ),
313
+ level = message .get ("level" , None ),
314
+ timestamp = message .get ("timestamp" , None ),
315
+ html = message .get ("html" , None ),
316
+ source = source ,
317
+ lineno = line ,
318
+ column = column ,
319
+ ),
247
320
),
248
321
)
249
322
@@ -305,7 +378,7 @@ def enqueue(
305
378
306
379
items = list (reversed (list (enqueue (cast (running .model .TestSuite , data )))))
307
380
308
- Debugger .instance ().send_event (self , Event (event = "robotEnqueued" , body = { " items" : items } ))
381
+ Debugger .instance ().send_event (self , Event (event = "robotEnqueued" , body = RobotEnqueuedEventBody ( items ) ))
309
382
310
383
self ._event_sended = True
311
384
@@ -337,6 +410,8 @@ def report_status(
337
410
if isinstance (result_item , result .TestCase )
338
411
else ""
339
412
),
413
+ source = str (normalized_path (Path (result_item .source ))) if result_item .source else None ,
414
+ lineno = data_item .lineno if data_item else None ,
340
415
),
341
416
),
342
417
)
0 commit comments