@@ -237,8 +237,10 @@ def send_message(self, method_name: str, params: Optional[dict]) -> None:
237
237
self .process .stdin .write (rpc_message .encode ("utf-8" ))
238
238
self .process .stdin .flush ()
239
239
240
- def call_method (self , method_name : str , params : Optional [dict ]) -> Any :
240
+ def call_method (self , method_name : str , params : Optional [dict ], expects_response : bool = True ) -> Any :
241
241
self .send_message (method_name , params )
242
+ if not expects_response :
243
+ return None
242
244
return self .receive_message ()
243
245
244
246
def send_notification (self , name : str , params : Optional [dict ] = None ) -> None :
@@ -484,6 +486,8 @@ def parseRequestAndResponse(self) -> RequestAndResponse:
484
486
if self .at_end ():
485
487
raise TestParserException (ret , "Request body not found" )
486
488
489
+ if self .at_end ():
490
+ return self .RequestAndResponse (** ret )
487
491
488
492
# Parse response header
489
493
if self .current_line ().startswith (RESPONSE_START ):
@@ -492,8 +496,6 @@ def parseRequestAndResponse(self) -> RequestAndResponse:
492
496
raise TestParserException (ret , "Response header malformed" )
493
497
ret ["response" ] = self .current_line ()[len (RESPONSE_START ):] + "\n "
494
498
ret ["responseBegin" ] = self .position ()
495
- else :
496
- raise TestParserException (ret , "Response header not found" )
497
499
498
500
self .next_line ()
499
501
@@ -568,7 +570,9 @@ def test_diagnostics(self):
568
570
569
571
# Process diagnostics first
570
572
self .expected_diagnostics = next (self .parsed_testcases )
571
- assert isinstance (self .expected_diagnostics , TestParser .Diagnostics ) is True
573
+ assert isinstance (self .expected_diagnostics , TestParser .Diagnostics )
574
+ if not self .expected_diagnostics .has_header :
575
+ return
572
576
573
577
expected_diagnostics_per_file = self .expected_diagnostics .tests
574
578
@@ -723,7 +727,14 @@ def run_testcase(self, testcase: TestParser.RequestAndResponse):
723
727
if 'textDocument' not in requestBodyJson :
724
728
requestBodyJson ['textDocument' ] = { 'uri' : self .suite .get_test_file_uri (self .test_name , self .sub_dir ) }
725
729
726
- actualResponseJson = self .solc .call_method (testcase .method , requestBodyJson )
730
+ actualResponseJson = self .solc .call_method (
731
+ testcase .method ,
732
+ requestBodyJson ,
733
+ expects_response = testcase .response is not None
734
+ )
735
+
736
+ if testcase .response is None :
737
+ return
727
738
728
739
# simplify response
729
740
if "result" in actualResponseJson :
@@ -1445,8 +1456,11 @@ def test_generic(self, solc: JsonRpcProcess) -> None:
1445
1456
1446
1457
for sub_dir in map (lambda filepath : filepath .name , sub_dirs ):
1447
1458
tests = map (
1448
- lambda filename , sd = sub_dir : sd + "/" + filename [:- len (".sol" )],
1449
- os .listdir (f"{ self .project_root_dir } /{ sub_dir } " )
1459
+ lambda file_object , sd = sub_dir : sd + "/" + file_object .name [:- len (".sol" )],
1460
+ filter (
1461
+ lambda filepath : filepath .is_file () and filepath .name .endswith ('.sol' ),
1462
+ os .scandir (f"{ self .project_root_dir } /{ sub_dir } " )
1463
+ )
1450
1464
)
1451
1465
1452
1466
tests = map (
0 commit comments