Skip to content

Commit

Permalink
Merge pull request #514 from elopez/dev-windows-tests-4
Browse files Browse the repository at this point in the history
Re-enable dapp tests on Windows
  • Loading branch information
msooseth authored Jul 30, 2024
2 parents 2d37ede + 4a1c44a commit 217d5ac
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: foundry-rs/foundry-toolchain@v1
- run: |
echo FOUNDRY_PATH="$(dirname "$(which forge)")" >> "$GITHUB_ENV"
shell: bash
- uses: msys2/setup-msys2@v2
with:
msystem: CLANG64
Expand Down Expand Up @@ -213,12 +216,12 @@ jobs:
- name: run tests
run: |
export PATH="$EVM_PATH:$CVC5_PATH:$BITWUZLA_PATH:$DAPP_SOLC_PATH:$HASKELL_PATHS:$PATH"
export PATH="$EVM_PATH:$CVC5_PATH:$BITWUZLA_PATH:$DAPP_SOLC_PATH:$FOUNDRY_PATH:$HASKELL_PATHS:$PATH"
cabal run test
- name: run rpc tests
run: |
export PATH="$HASKELL_PATHS:$PATH"
export PATH="$FOUNDRY_PATH:$HASKELL_PATHS:$PATH"
cabal run rpc-tests
- name: run ethereum tests
Expand Down
23 changes: 20 additions & 3 deletions test/EVM/Test/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import Data.String.Here
import Data.Text (Text)
import Data.Text qualified as T
import Data.Text.IO qualified as T
import GHC.IO.Handle (hClose)
import GHC.IO.Exception (IOErrorType(..))
import GHC.Natural
import Paths_hevm qualified as Paths
import System.Directory
import System.FilePath ((</>))
import System.IO.Temp
import System.Process
import System.Exit
import System.IO
import System.IO.Error (mkIOError)

import EVM.Dapp (dappInfo, emptyDapp)
import EVM.Fetch (RpcInfo)
Expand Down Expand Up @@ -65,6 +67,21 @@ testOpts solvers root buildOutput match maxIter allowFFI rpcinfo = do
, ffiAllowed = allowFFI
}

processFailedException :: String -> String -> [String] -> Int -> IO a
processFailedException fun cmd args exit_code =
ioError (mkIOError OtherError (fun ++ ": " ++ cmd ++
concatMap ((' ':) . show) args ++
" (exit " ++ show exit_code ++ ")")
Nothing Nothing)

callProcessCwd :: FilePath -> [String] -> FilePath -> IO ()
callProcessCwd cmd args cwd = do
exit_code <- withCreateProcess (proc cmd args) { cwd = Just cwd, delegate_ctlc = True } $ \_ _ _ p ->
waitForProcess p
case exit_code of
ExitSuccess -> return ()
ExitFailure r -> processFailedException "callProcess" cmd args r

compile :: App m => ProjectType -> FilePath -> FilePath -> m (Either String BuildOutput)
compile DappTools root src = do
json <- liftIO $ compileWithDSTest src
Expand Down Expand Up @@ -98,8 +115,8 @@ compile foundryType root src = do
_ <- readProcessWithExitCode "git" ["init", tld] ""
callProcess "git" ["config", "--file", tld </> ".git" </> "config", "user.name", "'hevm'"]
callProcess "git" ["config", "--file", tld </> ".git" </> "config", "user.email", "'[email protected]'"]
callProcess "git" ["--git-dir", tld </> ".git", "--work-tree", tld, "add", tld]
_ <- readProcessWithExitCode "git" ["--git-dir", tld </> ".git", "--work-tree", tld, "--no-gpg-sign", "commit", "-m"] ""
callProcessCwd "git" ["add", "."] tld
callProcessCwd "git" ["commit", "-m", "", "--allow-empty-message", "--no-gpg-sign"] tld
pure ()

-- We don't want to depend on dapptools here, so we cheat and just call solc with the same options that dapp itself uses
Expand Down
8 changes: 1 addition & 7 deletions test/rpc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
module Main where

import Test.Tasty
import Test.Tasty.ExpectedFailure
import Test.Tasty.HUnit
import System.Info (os)

import Data.Maybe
import Data.Map qualified as Map
Expand Down Expand Up @@ -34,10 +32,6 @@ rpcEnv = Env { config = defaultConfig }
test :: TestName -> ReaderT Env IO () -> TestTree
test a b = testCase a $ runEnv rpcEnv b

ignoreTestWindows :: String -> TestTree -> TestTree
ignoreTestWindows reason t | os == "mingw32" = ignoreTestBecause ("unsupported on Windows: " <> reason) t
| otherwise = t

main :: IO ()
main = defaultMain tests

Expand Down Expand Up @@ -75,7 +69,7 @@ tests = testGroup "rpc"
]
, testGroup "execution with remote state"
-- execute against remote state from a ds-test harness
[ ignoreTestWindows "git command failure" $ test "dapp-test" $ do
[ test "dapp-test" $ do
let testFile = "test/contracts/pass/rpc.sol"
res <- runSolidityTestCustom testFile ".*" Nothing Nothing False testRpcInfo Foundry
liftIO $ assertEqual "test result" True res
Expand Down
7 changes: 1 addition & 6 deletions test/test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import Data.Word (Word8)
import GHC.Conc (getNumProcessors)
import System.Directory
import System.Environment
import System.Info (os)
import Test.Tasty
import Test.Tasty.QuickCheck hiding (Failure, Success)
import Test.QuickCheck.Instances.Text()
Expand Down Expand Up @@ -112,10 +111,6 @@ main = defaultMain tests
runSubSet :: String -> IO ()
runSubSet p = defaultMain . applyPattern p $ tests

ignoreTestWindows :: String -> TestTree -> TestTree
ignoreTestWindows reason t | os == "mingw32" = ignoreTestBecause ("unsupported on Windows: " <> reason) t
| otherwise = t

tests :: TestTree
tests = testGroup "hevm"
[ Tracing.tests
Expand Down Expand Up @@ -1248,7 +1243,7 @@ tests = testGroup "hevm"
Partial _ _ (JumpIntoSymbolicCode _ _) -> assertBoolM "" True
_ -> assertBoolM "did not encounter expected partial node" False
]
, ignoreTestWindows "odd Git failures" $ testGroup "Dapp-Tests"
, testGroup "Dapp-Tests"
[ test "Trivial-Pass" $ do
let testFile = "test/contracts/pass/trivial.sol"
runSolidityTest testFile ".*" >>= assertEqualM "test result" True
Expand Down

0 comments on commit 217d5ac

Please sign in to comment.