Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Windows support after crytic-compile changes #1235

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/Echidna/Solidity.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
Loading