From d741083d45aa327370f70bb44b473046d7f4ea9f 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 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/Echidna/Solidity.hs b/lib/Echidna/Solidity.hs index 2c6b4c266..e124016ce 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,17 @@ 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 n) cs + isMatch n 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