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

test: re-enable dapp-test on Windows #5

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
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", "'hevm@hevm.dev'"]
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
Loading