@@ -238,7 +238,6 @@ async def generate(suite: TestSuite) -> TestItem:
238
238
else None ,
239
239
)
240
240
241
- # await self.parent.diagnostics.ensure_workspace_loaded()
242
241
await self .parent .robot_workspace .documents_loaded .wait ()
243
242
244
243
start = time .monotonic ()
@@ -247,107 +246,107 @@ async def generate(suite: TestSuite) -> TestItem:
247
246
248
247
workspace_path = Uri (workspace_folder ).to_path ()
249
248
canceled = False
250
- with LOGGER .cache_only :
251
- try :
252
- config = await self .get_config (workspace_folder )
253
- rpa_mode = config .get_rpa_mode () if config is not None else None
254
- languages = await self .parent .documents_cache .get_workspace_languages (workspace_folder )
249
+ LOGGER ._cache_only = True
250
+ try :
251
+ config = await self .get_config (workspace_folder )
252
+ rpa_mode = config .get_rpa_mode () if config is not None else None
253
+ languages = await self .parent .documents_cache .get_workspace_languages (workspace_folder )
255
254
256
- if paths is None and config is not None :
257
- paths = config .paths
255
+ if paths is None and config is not None :
256
+ paths = config .paths
258
257
259
- if paths and len (paths ):
258
+ if paths and len (paths ):
260
259
261
- def normalize_paths (paths : List [str ]) -> Iterator [str ]:
260
+ def normalize_paths (paths : List [str ]) -> Iterator [str ]:
262
261
263
- for path in paths :
262
+ for path in paths :
264
263
265
- p = Path (path )
264
+ p = Path (path )
266
265
267
- if not p .is_absolute ():
268
- p = Path (workspace_path , p )
266
+ if not p .is_absolute ():
267
+ p = Path (workspace_path , p )
269
268
270
- if p .exists ():
271
- yield str (p )
269
+ if p .exists ():
270
+ yield str (p )
272
271
273
- def nonexisting_paths (paths : List [str ]) -> Iterator [str ]:
272
+ def nonexisting_paths (paths : List [str ]) -> Iterator [str ]:
274
273
275
- for path in paths :
274
+ for path in paths :
276
275
277
- p = Path (path )
276
+ p = Path (path )
278
277
279
- if not p .is_absolute ():
280
- p = Path (workspace_path , p )
278
+ if not p .is_absolute ():
279
+ p = Path (workspace_path , p )
281
280
282
- if not p .exists ():
283
- yield str (p )
281
+ if not p .exists ():
282
+ yield str (p )
284
283
285
- valid_paths = [i for i in normalize_paths (paths )]
284
+ valid_paths = [i for i in normalize_paths (paths )]
286
285
287
- if get_robot_version () >= (6 , 0 ):
288
- builder = TestSuiteBuilder (
289
- included_suites = suites if suites else None ,
290
- rpa = rpa_mode ,
291
- lang = languages ,
292
- )
293
- else :
294
- builder = TestSuiteBuilder (included_suites = suites if suites else None , rpa = rpa_mode )
286
+ if get_robot_version () >= (6 , 0 ):
287
+ builder = TestSuiteBuilder (
288
+ included_suites = suites if suites else None ,
289
+ rpa = rpa_mode ,
290
+ lang = languages ,
291
+ )
292
+ else :
293
+ builder = TestSuiteBuilder (included_suites = suites if suites else None , rpa = rpa_mode )
295
294
296
- suite : Optional [TestSuite ] = builder .build (* valid_paths ) if valid_paths else None
297
- suite_item = [await generate (suite )] if suite else []
295
+ suite : Optional [TestSuite ] = builder .build (* valid_paths ) if valid_paths else None
296
+ suite_item = [await generate (suite )] if suite else []
298
297
299
- return [
300
- TestItem (
301
- type = "workspace" ,
302
- id = str (Path .cwd ().resolve ()),
303
- label = Path .cwd ().name ,
304
- longname = Path .cwd ().name ,
305
- uri = str (Uri .from_path (Path .cwd ())),
306
- children = [
307
- * suite_item ,
308
- * [
309
- TestItem (
310
- type = "error" ,
311
- id = f"{ i } ;ERROR" ,
312
- longname = "error" ,
313
- label = i ,
314
- error = f"Parsing '{ i } ' failed: File or directory to does not exist." ,
315
- )
316
- for i in nonexisting_paths (paths )
317
- ],
318
- ],
319
- )
320
- ]
321
- else :
322
- if get_robot_version () >= (6 , 0 ):
323
- builder = TestSuiteBuilder (
324
- included_suites = suites if suites else None ,
325
- rpa = rpa_mode ,
326
- lang = languages ,
327
- )
328
- else :
329
- builder = TestSuiteBuilder (included_suites = suites if suites else None , rpa = rpa_mode )
330
- return [await generate (builder .build (str (workspace_path )))]
331
- except (SystemExit , KeyboardInterrupt ):
332
- raise
333
- except asyncio .CancelledError :
334
- canceled = True
335
- self ._logger .info ("Tests discovery canceled" )
336
- raise
337
- except BaseException as e :
338
- self ._logger .info (f"Failed to discover tests: { e } " )
339
298
return [
340
299
TestItem (
341
- type = "error" ,
342
- id = str (Uri .from_path (Path .cwd ().resolve ())),
343
- longname = "error" ,
300
+ type = "workspace" ,
301
+ id = str (Path .cwd ().resolve ()),
344
302
label = Path .cwd ().name ,
345
- error = str (e ),
303
+ longname = Path .cwd ().name ,
304
+ uri = str (Uri .from_path (Path .cwd ())),
305
+ children = [
306
+ * suite_item ,
307
+ * [
308
+ TestItem (
309
+ type = "error" ,
310
+ id = f"{ i } ;ERROR" ,
311
+ longname = "error" ,
312
+ label = i ,
313
+ error = f"Parsing '{ i } ' failed: File or directory to does not exist." ,
314
+ )
315
+ for i in nonexisting_paths (paths )
316
+ ],
317
+ ],
346
318
)
347
319
]
348
- finally :
349
- if not canceled :
350
- self ._logger .info (f"Tests discovery took { time .monotonic () - start } s" )
320
+ else :
321
+ if get_robot_version () >= (6 , 0 ):
322
+ builder = TestSuiteBuilder (
323
+ included_suites = suites if suites else None ,
324
+ rpa = rpa_mode ,
325
+ lang = languages ,
326
+ )
327
+ else :
328
+ builder = TestSuiteBuilder (included_suites = suites if suites else None , rpa = rpa_mode )
329
+ return [await generate (builder .build (str (workspace_path )))]
330
+ except (SystemExit , KeyboardInterrupt ):
331
+ raise
332
+ except asyncio .CancelledError :
333
+ canceled = True
334
+ self ._logger .info ("Tests discovery canceled" )
335
+ raise
336
+ except BaseException as e :
337
+ self ._logger .info (f"Failed to discover tests: { e } " )
338
+ return [
339
+ TestItem (
340
+ type = "error" ,
341
+ id = str (Uri .from_path (Path .cwd ().resolve ())),
342
+ longname = "error" ,
343
+ label = Path .cwd ().name ,
344
+ error = str (e ),
345
+ )
346
+ ]
347
+ finally :
348
+ if not canceled :
349
+ self ._logger .info (f"Tests discovery took { time .monotonic () - start } s" )
351
350
352
351
@rpc_method (name = "robot/discovering/getTestsFromDocument" , param_type = GetTestsParams )
353
352
@threaded ()
0 commit comments