aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYann Herklotz <git@ymhg.org>2019-05-13 16:32:41 +0100
committerYann Herklotz <git@ymhg.org>2019-05-13 16:32:41 +0100
commit98c6701f48d3e06eb0f2fcd590d0330aec8b5a9b (patch)
tree0f7d04a48fd28b9b14da74686b3fac27515362a4 /src
parent2fa0419fcd066137e0fc2fdc6c8f4128a4a1e663 (diff)
downloadverismith-98c6701f48d3e06eb0f2fcd590d0330aec8b5a9b.tar.gz
verismith-98c6701f48d3e06eb0f2fcd590d0330aec8b5a9b.zip
Add ResultT to Sh conversion
Diffstat (limited to 'src')
-rw-r--r--src/VeriFuzz.hs4
-rw-r--r--src/VeriFuzz/Sim/Internal.hs10
2 files changed, 12 insertions, 2 deletions
diff --git a/src/VeriFuzz.hs b/src/VeriFuzz.hs
index 054db72..c448c0b 100644
--- a/src/VeriFuzz.hs
+++ b/src/VeriFuzz.hs
@@ -415,7 +415,7 @@ checkEquivalence src dir = shellyFailDir $ do
setenv "VERIFUZZ_ROOT" curr
cd (fromText dir)
catch_sh
- ( (runResultT $ runEquiv defaultYosys (Just defaultVivado) src)
+ ( (runResultT $ runEquiv defaultYosys defaultVivado src)
>> return True
)
((\_ -> return False) :: RunFailed -> Sh Bool)
@@ -442,7 +442,7 @@ runEquivalence seed gm t d k i = do
_ <-
catch_sh
( runResultT
- $ runEquiv defaultYosys (Just defaultVivado) srcInfo
+ $ runEquiv defaultYosys defaultVivado srcInfo
>> liftSh (logger "Test OK")
)
$ onFailure n
diff --git a/src/VeriFuzz/Sim/Internal.hs b/src/VeriFuzz/Sim/Internal.hs
index a11fbd3..091520c 100644
--- a/src/VeriFuzz/Sim/Internal.hs
+++ b/src/VeriFuzz/Sim/Internal.hs
@@ -14,6 +14,7 @@ Class of the simulator and the synthesize tool.
module VeriFuzz.Sim.Internal
( ResultSh
+ , resultSh
, Tool(..)
, Simulator(..)
, Synthesiser(..)
@@ -39,6 +40,7 @@ where
import Control.Lens
import Control.Monad (forM, void)
+import Control.Monad.Catch (throwM)
import Data.Bits (shiftL)
import Data.ByteString (ByteString)
import qualified Data.ByteString as B
@@ -51,6 +53,7 @@ import Prelude hiding (FilePath)
import Shelly
import Shelly.Lifted (MonadSh, liftSh)
import System.FilePath.Posix (takeBaseName)
+import VeriFuzz.Internal
import VeriFuzz.Result
import VeriFuzz.Verilog.AST
@@ -95,6 +98,13 @@ class Tool a => Synthesiser a where
-- with also has those instances.
type ResultSh = ResultT Failed Sh
+resultSh :: ResultSh a -> Sh a
+resultSh s = do
+ result <- runResultT s
+ case result of
+ Fail e -> throwM . RunFailed "" [] 1 $ showT e
+ Pass s' -> return s'
+
checkPresent :: FilePath -> Text -> Sh (Maybe Text)
checkPresent fp t = do
errExit False $ run_ "grep" [t, toTextIgnore fp]