Merge pull request #193 from crytic/return-codes

`Open _` should also `exitSuccess` because it is not reported as a failure in the UI
pull/199/head
Will Song 6 years ago committed by GitHub
commit a19b9b4fc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      lib/Echidna/Campaign.hs
  2. 9
      src/Main.hs

@ -86,6 +86,12 @@ isDone :: (MonadReader x m, Has CampaignConf x) => Campaign -> m Bool
isDone (Campaign ts _) = view (hasLens . to (liftM2 (,) testLimit shrinkLimit)) <&> \(tl, sl) ->
all (\case Open i -> i >= tl; Large i _ -> i >= sl; _ -> True) $ snd <$> ts
-- | Given a 'Campaign', check if the test results should be reported as a
-- success or a failure.
isSuccess :: Campaign -> Bool
isSuccess (Campaign ts _) =
any (\case { Passed -> True; Open _ -> True; _ -> False; }) $ snd <$> ts
-- | Given an initial 'VM' state and a @('SolTest', 'TestState')@ pair, as well as possibly a sequence
-- of transactions and the state after evaluation, see if:
-- (0): The test is past its 'testLimit' or 'shrinkLimit' and should be presumed un[solve|shrink]able

@ -35,8 +35,7 @@ opts = info (options <**> helper) $ fullDesc
main :: IO ()
main = do (Options f c cov conf) <- execParser opts
cfg <- maybe (pure defaultConfig) parseConfig conf
Campaign r _ <- runReaderT (loadSolTests f (pack <$> c) >>= \(v,w,ts) -> ui v w ts) $
cfg & cConf %~ if cov then \k -> k {knownCoverage = Just mempty} else id
if any (/= Passed) $ snd <$> r then exitWith $ ExitFailure 1
else exitSuccess
cfg <- maybe (pure defaultConfig) parseConfig conf
cpg <- runReaderT (loadSolTests f (pack <$> c) >>= \(v,w,ts) -> ui v w ts) $
cfg & cConf %~ if cov then \k -> k {knownCoverage = Just mempty} else id
if not . isSuccess $ cpg then exitWith $ ExitFailure 1 else exitSuccess

Loading…
Cancel
Save