aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <git@ymhg.org>2019-04-24 11:30:24 +0100
committerYann Herklotz <git@ymhg.org>2019-04-24 11:30:24 +0100
commite116c73bc75188db5cae0cda3f5251c0f69b822b (patch)
treea96598abafdf896fbf23d4eb45761b99f6f03560
parent9c96914d48e798294e20ccd863fdb25fde1c39b9 (diff)
downloadverismith-e116c73bc75188db5cae0cda3f5251c0f69b822b.tar.gz
verismith-e116c73bc75188db5cae0cda3f5251c0f69b822b.zip
Add time and date by default
-rw-r--r--app/Main.hs7
-rw-r--r--src/VeriFuzz/Fuzz.hs20
2 files changed, 20 insertions, 7 deletions
diff --git a/app/Main.hs b/app/Main.hs
index 3e14b03..4e6b3bc 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -199,10 +199,9 @@ getConfig = maybe (return V.defaultConfig) V.parseConfigFile
handleOpts :: Opts -> IO ()
handleOpts (Fuzz out configF _ _) = do
config <- getConfig configF
- _ <- V.runFuzz
- config
- V.defaultYosys
- (V.fuzzMultiple 5 (S.fromText out) (V.proceduralSrc "top" config))
+ _ <- V.runFuzz config
+ V.defaultYosys
+ (V.fuzzMultiple 5 Nothing (V.proceduralSrc "top" config))
return ()
handleOpts (Generate f c) = do
config <- getConfig c
diff --git a/src/VeriFuzz/Fuzz.hs b/src/VeriFuzz/Fuzz.hs
index dd3bfd4..c0e6117 100644
--- a/src/VeriFuzz/Fuzz.hs
+++ b/src/VeriFuzz/Fuzz.hs
@@ -34,6 +34,7 @@ import Control.Monad.Trans.State.Strict
import Data.ByteString (ByteString)
import Data.List (nubBy)
import Data.Text (Text)
+import qualified Data.Text as T
import Data.Time
import Hedgehog (Gen)
import qualified Hedgehog.Gen as Hog
@@ -165,9 +166,22 @@ fuzzInDir fp src = do
pop fp $ fuzz src
fuzzMultiple
- :: MonadFuzz m => Int -> FilePath -> Gen SourceInfo -> Fuzz m FuzzReport
+ :: MonadFuzz m
+ => Int
+ -> (Maybe FilePath)
+ -> Gen SourceInfo
+ -> Fuzz m FuzzReport
fuzzMultiple n fp src = do
- make fp
- void . pop fp $ forM [1 .. n] fuzzDir
+ x <- case fp of
+ Nothing -> do
+ ct <- liftIO getZonedTime
+ return
+ . fromText
+ . T.pack
+ $ "output_"
+ <> formatTime defaultTimeLocale "%Y-%m-%d_%H-%M-%S" ct
+ Just f -> return f
+ make x
+ void . pop x $ forM [1 .. n] fuzzDir
return mempty
where fuzzDir n' = fuzzInDir (fromText $ "fuzz_" <> showT n') src