@@ -12,8 +12,9 @@ import Data.String.Here
1212import Data.Text (Text )
1313import Data.Text qualified as T
1414import Data.Time (diffUTCTime , getCurrentTime )
15- import System.Directory (listDirectory , doesDirectoryExist )
1615import System.Environment (lookupEnv )
16+ import System.FilePath (makeRelative , normalise )
17+ import System.FilePath.Find (find , always , filePath , fileType , (&&?) , FileType (RegularFile ))
1718import Test.Tasty
1819import Test.Tasty.ExpectedFailure (ignoreTest )
1920import Test.Tasty.HUnit
@@ -432,7 +433,7 @@ yulEquivalenceTests = testGroup "Yul equivalence"
432433yulOptimizationsSolcTests :: TestTree
433434yulOptimizationsSolcTests = testCase " eq-all-yul-optimization-tests" $ do
434435 let opts = (defaultVeriOpts :: VeriOpts ) { iterConf = defaultIterConf {maxIter = Just 5 , askSmtIters = 20 , loopHeuristic = Naive }}
435- ignoredTests =
436+ ignoredTests = fmap normalise
436437 -- unbounded loop --
437438 [ " commonSubexpressionEliminator/branches_for.yul"
438439 , " conditionalSimplifier/no_opt_if_break_is_not_last.yul"
@@ -470,7 +471,7 @@ yulOptimizationsSolcTests = testCase "eq-all-yul-optimization-tests" $ do
470471 , " reasoningBasedSimplifier/mulcheck.yul"
471472 , " reasoningBasedSimplifier/smod.yul"
472473 , " fullSuite/abi_example1.yul"
473- , " yulOptimizerTests/ fullInliner/large_function_multi_use.yul"
474+ , " fullInliner/large_function_multi_use.yul"
474475 , " loadResolver/merge_known_write_with_distance.yul"
475476 , " loadResolver/second_mstore_with_delta.yul"
476477 , " rematerialiser/for_continue_2.yul"
@@ -574,8 +575,8 @@ yulOptimizationsSolcTests = testCase "eq-all-yul-optimization-tests" $ do
574575 , " equalStoreEliminator/transient_storage.yul"
575576 , " unusedStoreEliminator/tload.yul"
576577 , " unusedStoreEliminator/tstore.yul"
577- , " yulOptimizerTests/ fullSuite/transient_storage.yul"
578- , " yulOptimizerTests/ unusedPruner/transient_storage.yul"
578+ , " fullSuite/transient_storage.yul"
579+ , " unusedPruner/transient_storage.yul"
579580
580581 -- Bug in solidity, fixed in newer versions:
581582 -- https://github.com/ethereum/solidity/issues/15397#event-14116827816
@@ -592,22 +593,10 @@ yulOptimizationsSolcTests = testCase "eq-all-yul-optimization-tests" $ do
592593 ]
593594
594595 solcRepo <- fromMaybe (internalError " cannot find solidity repo" ) <$> (lookupEnv " HEVM_SOLIDITY_REPO" )
595- let testDir = solcRepo <> " /test/libyul/yulOptimizerTests"
596- dircontents <- listDirectory testDir
597- let
598- fullpaths = map ((testDir ++ " /" ) ++ ) dircontents
599- recursiveList :: [FilePath ] -> [FilePath ] -> IO [FilePath ]
600- recursiveList (a: ax) b = do
601- isdir <- doesDirectoryExist a
602- case isdir of
603- True -> do
604- fs <- listDirectory a
605- let fs2 = map ((a ++ " /" ) ++ ) fs
606- recursiveList (ax++ fs2) b
607- False -> recursiveList ax (a: b)
608- recursiveList [] b = pure b
609- files <- recursiveList fullpaths []
610- let filesFiltered = filter (\ file -> not $ any (`List.isInfixOf` file) ignoredTests) files
596+ let testDir = normalise $ solcRepo <> " /test/libyul/yulOptimizerTests"
597+ shouldIgnore fp = any (`List.isInfixOf` (makeRelative testDir fp)) ignoredTests
598+ isRegularFile = (== RegularFile ) <$> fileType
599+ filesFiltered <- find always (isRegularFile &&? (not . shouldIgnore <$> filePath)) testDir
611600
612601 -- Takes one file which follows the Solidity Yul optimizer unit tests format,
613602 -- extracts both the nonoptimized and the optimized versions, and checks equivalence.
0 commit comments