From 2b31d2a0e7822a98580097f6020287d132f7fd92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= Date: Wed, 10 Apr 2024 13:35:08 -0300 Subject: [PATCH] Fix Windows support after crytic-compile changes --- lib/Echidna/Solidity.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/Echidna/Solidity.hs b/lib/Echidna/Solidity.hs index 2c6b4c266..1c0a339d1 100644 --- a/lib/Echidna/Solidity.hs +++ b/lib/Echidna/Solidity.hs @@ -24,6 +24,7 @@ import System.Directory import System.Process (StdStream(..), readCreateProcessWithExitCode, proc, std_err) import System.Exit (ExitCode(..)) import System.FilePath (joinPath, splitDirectories, ()) +import System.FilePath.Posix qualified as FPP import System.IO (openFile, IOMode(..)) import System.Info (os) @@ -278,13 +279,16 @@ loadSpecified env name cs = do choose (c:_) Nothing = pure c choose _ (Just n) = maybe (throwM $ ContractNotFound n) pure $ - find (Data.Text.isSuffixOf (contractId n) . (.contractName)) cs - contractId n + find isMatch cs + isMatch s = (Data.Text.isSuffixOf (contractId rewriteOsPathSeparators n) . (.contractName)) s || + (Data.Text.isSuffixOf (contractId rewritePosixPathSeparators n) . (.contractName)) s + contractId rewrite n | T.any (== ':') n = let (splitPath, splitName) = T.breakOn ":" n - in rewritePathSeparators splitPath `T.append` splitName + in rewrite splitPath `T.append` splitName | otherwise = ":" `append` n - rewritePathSeparators = T.pack . joinPath . splitDirectories . T.unpack + rewriteOsPathSeparators = T.pack . joinPath . splitDirectories . T.unpack + rewritePosixPathSeparators = T.pack . FPP.joinPath . FPP.splitDirectories . T.unpack setUpFunction = ("setUp", []) -- | Given the results of 'loadSolidity', assuming a single-contract test, get everything ready