@@ -585,11 +585,22 @@ async def get_command_line_variables(self) -> List[VariableDefinition]:
585
585
name , args = split_args_from_name_or_path (str (variable_file ))
586
586
try :
587
587
lib_doc = await self .get_libdoc_for_variables_import (
588
- name , tuple (args ), str (self .folder .to_path ()), self , resolve_command_line_vars = False
588
+ name ,
589
+ tuple (args ),
590
+ str (self .folder .to_path ()),
591
+ self ,
592
+ resolve_variables = False ,
593
+ resolve_command_line_vars = False ,
589
594
)
590
595
if lib_doc is not None :
591
596
command_line_vars += lib_doc .variables
592
597
598
+ if lib_doc .errors :
599
+ # TODO add diagnostics
600
+ for error in lib_doc .errors :
601
+ self ._logger .error (
602
+ lambda : f"{ error .type_name } : { error .message } in { error .source } :{ error .line_no } "
603
+ )
593
604
except (SystemExit , KeyboardInterrupt , asyncio .CancelledError ):
594
605
raise
595
606
except BaseException as e :
@@ -604,11 +615,23 @@ async def get_command_line_variables(self) -> List[VariableDefinition]:
604
615
name , args = split_args_from_name_or_path (variable_file )
605
616
try :
606
617
lib_doc = await self .get_libdoc_for_variables_import (
607
- name , tuple (args ), str (self .folder .to_path ()), self , resolve_command_line_vars = False
618
+ name ,
619
+ tuple (args ),
620
+ str (self .folder .to_path ()),
621
+ self ,
622
+ resolve_variables = False ,
623
+ resolve_command_line_vars = False ,
608
624
)
609
625
if lib_doc is not None :
610
626
command_line_vars += lib_doc .variables
611
627
628
+ if lib_doc .errors :
629
+ # TODO add diagnostics
630
+ for error in lib_doc .errors :
631
+ self ._logger .error (
632
+ lambda : f"{ error .type_name } : { error .message } in { error .source } :{ error .line_no } "
633
+ )
634
+
612
635
except (SystemExit , KeyboardInterrupt , asyncio .CancelledError ):
613
636
raise
614
637
except BaseException as e :
@@ -878,12 +901,16 @@ async def get_variables_meta(
878
901
name : str ,
879
902
base_dir : str = "." ,
880
903
variables : Optional [Dict [str , Optional [Any ]]] = None ,
904
+ resolve_variables : bool = True ,
905
+ resolve_command_line_vars : bool = True ,
881
906
) -> Tuple [Optional [LibraryMetaData ], str ]:
882
907
try :
883
908
import_name = await self .find_variables (
884
909
name ,
885
910
base_dir = base_dir ,
886
911
variables = variables ,
912
+ resolve_variables = resolve_variables ,
913
+ resolve_command_line_vars = resolve_command_line_vars ,
887
914
)
888
915
889
916
result : Optional [LibraryMetaData ] = None
@@ -935,7 +962,7 @@ async def get_variables_meta(
935
962
except BaseException :
936
963
pass
937
964
938
- return None , import_name
965
+ return None , name
939
966
940
967
async def find_library (self , name : str , base_dir : str , variables : Optional [Dict [str , Any ]] = None ) -> str :
941
968
return await self ._library_files_cache .get (self ._find_library , name , base_dir , variables )
@@ -986,19 +1013,35 @@ async def __find_resource(
986
1013
987
1014
return str (find_file_ex (name , base_dir , file_type ))
988
1015
989
- async def find_variables (self , name : str , base_dir : str , variables : Optional [Dict [str , Any ]] = None ) -> str :
990
- return await self ._variables_files_cache .get (self .__find_variables , name , base_dir , variables )
1016
+ async def find_variables (
1017
+ self ,
1018
+ name : str ,
1019
+ base_dir : str ,
1020
+ variables : Optional [Dict [str , Any ]] = None ,
1021
+ resolve_variables : bool = True ,
1022
+ resolve_command_line_vars : bool = True ,
1023
+ ) -> str :
1024
+ return await self ._variables_files_cache .get (
1025
+ self .__find_variables , name , base_dir , variables , resolve_command_line_vars
1026
+ )
991
1027
992
1028
@_logger .call
993
- async def __find_variables (self , name : str , base_dir : str , variables : Optional [Dict [str , Any ]] = None ) -> str :
1029
+ async def __find_variables (
1030
+ self ,
1031
+ name : str ,
1032
+ base_dir : str ,
1033
+ variables : Optional [Dict [str , Any ]] = None ,
1034
+ resolve_variables : bool = True ,
1035
+ resolve_command_line_vars : bool = True ,
1036
+ ) -> str :
994
1037
from robot .variables .search import contains_variable
995
1038
996
- if contains_variable (name , "$@&%" ):
1039
+ if resolve_variables and contains_variable (name , "$@&%" ):
997
1040
return find_variables (
998
1041
name ,
999
1042
str (self .folder .to_path ()),
1000
1043
base_dir ,
1001
- await self .get_resolvable_command_line_variables (),
1044
+ await self .get_resolvable_command_line_variables () if resolve_command_line_vars else None ,
1002
1045
variables ,
1003
1046
)
1004
1047
@@ -1258,19 +1301,23 @@ async def get_libdoc_for_variables_import(
1258
1301
base_dir : str ,
1259
1302
sentinel : Any = None ,
1260
1303
variables : Optional [Dict [str , Any ]] = None ,
1304
+ resolve_variables : bool = True ,
1261
1305
resolve_command_line_vars : bool = True ,
1262
1306
) -> VariablesDoc :
1263
1307
source = await self .find_variables (
1264
1308
name ,
1265
1309
base_dir ,
1266
1310
variables ,
1311
+ resolve_variables = resolve_variables ,
1312
+ resolve_command_line_vars = resolve_command_line_vars ,
1267
1313
)
1268
1314
1269
1315
async def _get_libdoc (name : str , args : Tuple [Any , ...], working_dir : str , base_dir : str ) -> VariablesDoc :
1270
1316
meta , source = await self .get_variables_meta (
1271
1317
name ,
1272
1318
base_dir ,
1273
1319
variables ,
1320
+ resolve_command_line_vars = resolve_command_line_vars ,
1274
1321
)
1275
1322
1276
1323
self ._logger .debug (lambda : f"Load variables { source } { args !r} " )
0 commit comments