@@ -230,8 +230,6 @@ def test_valid_runs(self) -> None:
230230 run_flags = [f"{ _p ('A.sol' )} :B" , '--verify' , f"B:{ _p ('spec1.spec' )} " ])
231231 suite .expect_success (description = 'multiple files single assert' ,
232232 run_flags = [_p ('A.sol' ), _p ('B.sol' ), '--verify' , f"A:{ _p ('spec1.spec' )} " ])
233- suite .expect_success (description = 'file is repeated' ,
234- run_flags = [f"{ _p ('A.sol' )} :B" , f"{ _p ('A.sol' )} :B" , '--verify' , f"B:{ _p ('spec1.spec' )} " ])
235233 suite .expect_success (description = '2 contracts in a single file' ,
236234 run_flags = [f"{ _p ('A.sol' )} :B" , _p ('A.sol' ), '--verify' , f"B:{ _p ('spec1.spec' )} " ])
237235 suite .expect_success (description = '--verify with spec file' ,
@@ -355,8 +353,6 @@ def test_valid_runs(self) -> None:
355353 suite .expect_success (description = 'valid --struct_link multiple entries' ,
356354 run_flags = [_p ('A.sol' ), _p ('B.sol' ), '--verify' , f"A:{ _p ('spec1.spec' )} " , '--struct_link' ,
357355 'A:1=B' , 'A:2=B' , 'A:1009=A' ])
358- suite .expect_success (description = 'valid --struct_link duplicate entries' ,
359- run_flags = [_p ('A.sol' ), '--verify' , f"A:{ _p ('spec1.spec' )} " , '--struct_link' , 'A:0XC=A' , 'A:0XC=A' ])
360356 suite .expect_success (description = 'valid --build_only' ,
361357 run_flags = [_p ('A.sol' ), '--verify' , f"A:{ _p ('spec1.spec' )} " , '--build_only' ])
362358 suite .expect_success (description = 'valid --build_only duplicate entries' ,
@@ -548,6 +544,10 @@ def test_invalid_runs(self) -> None:
548544 run_flags = [_p ('A.sol' ), '--verify' , f"A:{ _p ('spec1.spec' )} " , '--compilation_steps_only' ,
549545 '--build_only' ],
550546 expected = "cannot use both 'compilation_steps_only' and 'build_only'" )
547+ suite .expect_failure (description = 'valid --struct_link duplicate entries' ,
548+ run_flags = [_p ('A.sol' ), '--verify' , f"A:{ _p ('spec1.spec' )} " ,
549+ '--struct_link' , 'A:0XC=A' , 'A:0XC=A' ],
550+ expected = "The value of attribute 'struct_link' contains duplicate entries" )
551551 suite .expect_failure (description = "illegal struct_link" ,
552552 run_flags = [_p ('tac_file.conf' ), '--struct_link' , 'tac_file:0=tac_file' ],
553553 expected = "'struct_link' argument tac_file:0=tac_file is illegal" )
@@ -585,6 +585,9 @@ def test_invalid_runs(self) -> None:
585585 suite .expect_failure (description = "other files with conf file" ,
586586 run_flags = [_p ('tac_file.conf' ), _p ('empty.tac' )],
587587 expected = "No other files are allowed when using a config file" )
588+ suite .expect_failure (description = 'file is repeated' ,
589+ run_flags = [f"{ _p ('A.sol' )} :B" , f"{ _p ('A.sol' )} :B" , '--verify' , f"B:{ _p ('spec1.spec' )} " ],
590+ expected = "The value of attribute 'files' contains duplicate entries" )
588591 suite .expect_failure (description = "illegal contract in verify" ,
589592 run_flags = [_p ('empty.tac' ), '--verify' , f"A:{ _p ('spec1.spec' )} " ],
590593 expected = "'verify' argument, A, doesn't match any contract name" )
@@ -817,7 +820,7 @@ def test_package_file(self) -> None:
817820 def check_run (expect : List [str ]) -> None :
818821 packages_attr = getattr (result , 'packages' , None )
819822 assert packages_attr , f"{ description } : package is None"
820- got = sorted ([dep .split ('=' )[0 ] for dep in packages_attr ])
823+ got = sorted ([dep .split ('=' )[0 ]. rstrip ( '/' ) for dep in packages_attr ])
821824 assert expect == got , f"{ description } . Expected: { expect } . Got: { got } "
822825
823826 suite = TestUtil .ProverTestSuite (conf_file_template = _p ('mutation_conf_top_level.conf' ),
@@ -830,37 +833,44 @@ def check_run(expect: List[str]) -> None:
830833 assert not packages , f"expected 'packages' to be None. Got: { result .packages } "
831834
832835 remapping = "a=lib\n b=lib"
833- with open (Util .REMAPPINGS_FILE , "w" ) as file :
834- file .write (remapping )
835- description = f"running with { Util .REMAPPINGS_FILE } "
836- result = suite .expect_checkpoint (description = description )
837- check_run (['a' , 'b' ])
838-
839- remapping = '{"dependencies": {"c": "^3.4.1"},"devDependencies": {"d": "^5.0.8"}}'
840- with open (Util .PACKAGE_FILE , "w" ) as file :
841- file .write (remapping )
842- description = f"running with { Util .REMAPPINGS_FILE } and { Util .PACKAGE_FILE } "
843- result = suite .expect_checkpoint (description = description )
844- check_run (['a' , 'b' , 'c' , 'd' ])
836+ try :
837+ with open (Util .REMAPPINGS_FILE , "w" ) as file :
838+ file .write (remapping )
839+ description = f"running with { Util .REMAPPINGS_FILE } "
840+ result = suite .expect_checkpoint (description = description )
841+ check_run (['a' , 'b' ])
842+
843+ remapping = '{"dependencies": {"c": "^3.4.1"},"devDependencies": {"d": "^5.0.8"}}'
844+ with open (Util .PACKAGE_FILE , "w" ) as file :
845+ file .write (remapping )
846+ description = f"running with { Util .REMAPPINGS_FILE } and { Util .PACKAGE_FILE } "
847+ result = suite .expect_checkpoint (description = description )
848+ check_run (['a' , 'b' , 'c' , 'd' ])
849+ finally :
850+ Path (Util .REMAPPINGS_FILE ).unlink (missing_ok = True )
845851
846852 description = "--packages - ignore files"
847853 result = suite .expect_checkpoint (description = description , run_flags = ['--packages' , 'd=lib' ])
848854 check_run (['d' ])
849855
850856 # duplications
851857 remapping = "a=lib\n a=lib"
852- with open (Util .REMAPPINGS_FILE , "w" ) as file :
853- file .write (remapping )
854- description = f"identical duplicates in { Util .REMAPPINGS_FILE } "
855- suite .expect_success (description = description )
856- Path (Util .REMAPPINGS_FILE ).unlink (missing_ok = True )
858+ try :
859+ with open (Util .REMAPPINGS_FILE , "w" ) as file :
860+ file .write (remapping )
861+ description = f"identical duplicates in { Util .REMAPPINGS_FILE } "
862+ suite .expect_success (description = description )
863+ finally :
864+ Path (Util .REMAPPINGS_FILE ).unlink (missing_ok = True )
857865
858866 remapping = "a=lib\n a=lib2"
859- with open (Util .REMAPPINGS_FILE , "w" ) as file :
860- file .write (remapping )
861- description = f"non-identical duplicates in { Util .REMAPPINGS_FILE } "
862- suite .expect_failure (description = description , expected = "Conflicting values in remappings.txt for key 'a'" )
863- Path (Util .REMAPPINGS_FILE ).unlink (missing_ok = True )
867+ try :
868+ with open (Util .REMAPPINGS_FILE , "w" ) as file :
869+ file .write (remapping )
870+ description = f"non-identical duplicates in { Util .REMAPPINGS_FILE } "
871+ suite .expect_failure (description = description , expected = "Conflicting values in remappings.txt for key 'a'" )
872+ finally :
873+ Path (Util .REMAPPINGS_FILE ).unlink (missing_ok = True )
864874
865875 remapping = '{"dependencies": {"c": "^3.4.1"},"devDependencies": {"c": "^5.0.8"}}'
866876 with open (Util .PACKAGE_FILE , "w" ) as file :
@@ -870,24 +880,28 @@ def check_run(expect: List[str]) -> None:
870880 Path (Util .PACKAGE_FILE ).unlink (missing_ok = True )
871881
872882 remapping = "a=lib\n b=lib"
873- with open (Util .REMAPPINGS_FILE , "w" ) as file :
874- file .write (remapping )
875- remapping = '{"dependencies": {"b": "^3.4.1"},"devDependencies": {"c": "^5.0.8"}}'
876- with open (Util .PACKAGE_FILE , "w" ) as file :
877- file .write (remapping )
878- description = f"duplicates in { Util .REMAPPINGS_FILE } and Util.PACKAGE_FILE"
879- suite .expect_failure (description = description , expected = "package.json and remappings.txt include duplicated" )
880- Path (Util .REMAPPINGS_FILE ).unlink (missing_ok = True )
881- Path (Util .PACKAGE_FILE ).unlink (missing_ok = True )
883+ try :
884+ with open (Util .REMAPPINGS_FILE , "w" ) as file :
885+ file .write (remapping )
886+ remapping = '{"dependencies": {"b": "^3.4.1"},"devDependencies": {"c": "^5.0.8"}}'
887+ with open (Util .PACKAGE_FILE , "w" ) as file :
888+ file .write (remapping )
889+ description = f"duplicates in { Util .REMAPPINGS_FILE } and Util.PACKAGE_FILE"
890+ suite .expect_failure (description = description , expected = "package.json and remappings.txt include duplicated" )
891+ finally :
892+ Path (Util .REMAPPINGS_FILE ).unlink (missing_ok = True )
893+ Path (Util .PACKAGE_FILE ).unlink (missing_ok = True )
882894
883895
884896 remapping = "a=lib\n b=lib=lib2"
885- with open (Util .REMAPPINGS_FILE , "w" ) as file :
886- file .write (remapping )
897+ try :
898+ with open (Util .REMAPPINGS_FILE , "w" ) as file :
899+ file .write (remapping )
887900
888- description = f"remappings.txt with bad format"
889- suite .expect_failure (description = description , expected = "Invalid remapping in remappings.txt" )
890- Path (Util .REMAPPINGS_FILE ).unlink (missing_ok = True )
901+ description = f"remappings.txt with bad format"
902+ suite .expect_failure (description = description , expected = "Invalid remapping in remappings.txt" )
903+ finally :
904+ Path (Util .REMAPPINGS_FILE ).unlink (missing_ok = True )
891905
892906 def test_solc_args (self ) -> None :
893907
0 commit comments