test optparse

This commit is contained in:
Tom Sydney Kerckhove 2022-03-06 13:04:30 +01:00
parent 45274a7637
commit dce335cb25
4 changed files with 36 additions and 3 deletions

View File

@ -24,6 +24,7 @@ library
Feedback.Loop
Feedback.Loop.OptParse
Feedback.Test
Feedback.Test.OptParse
other-modules:
Paths_feedback
hs-source-dirs:

View File

@ -1,6 +1,3 @@
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module Feedback.Loop.OptParse where

View File

@ -1,5 +1,9 @@
module Feedback.Test where
import Feedback.Test.OptParse
runFeedbackTest :: IO ()
runFeedbackTest = do
sets <- getSettings
print sets
pure ()

View File

@ -0,0 +1,31 @@
{-# LANGUAGE RecordWildCards #-}
module Feedback.Test.OptParse where
import Control.Applicative
import Control.Monad
import Data.Map (Map)
import qualified Data.Map as M
import Feedback.Common.OptParse
import GHC.Generics (Generic)
import Text.Show.Pretty (pPrint)
getSettings :: IO TestSettings
getSettings = do
flags <- getFlags
env <- getEnvironment
config <- getConfiguration flags env
combineToTestSettings flags env config
data TestSettings = TestSettings
{ testSettingLoops :: !(Map String LoopSettings)
}
deriving (Show, Eq)
combineToTestSettings :: Flags -> Environment -> Maybe Configuration -> IO TestSettings
combineToTestSettings flags@Flags {..} environment mConf = do
testSettingLoops <-
traverse
(combineToLoopSettings flags environment (mConf >>= configOutputConfiguration))
(maybe M.empty configLoops mConf)
pure TestSettings {..}