Commits

dave4420 committed 0d4da54

Moved `propertyTester` to being an `Option` instead of a `Flag`.

Comments (0)

Files changed (1)

 
 data Options = Options {modeFromOptions :: Mode,
                         nfsFromOptions :: [String],
-                        flagsFromOptions :: Flags}
+                        flagsFromOptions :: Flags,
+                        propertyTester :: PropertyTester}
 data Mode = NormalMode | HelpMode | VersionMode
-noOptions = Options NormalMode [] defaultFlags
+noOptions = Options NormalMode [] defaultFlags QuickCheck1
 withModeOption mode opts = opts {modeFromOptions = mode}
 withNfOption nf opts = opts {nfsFromOptions = nf : nfsFromOptions opts}
 withNfsOption nfs opts = opts {nfsFromOptions = nfs}
 alterFlags f opts = opts {flagsFromOptions = f (flagsFromOptions opts)}
 
 data Flags = Flags {pkgsFromFlags :: [PkgFlag],
-                    ndsImportFromFlags :: [FilePath],
-                    propertyTester :: PropertyTester}
+                    ndsImportFromFlags :: [FilePath]}
 data PkgFlag = ExposePkg String
              | HidePkg String
              | IgnorePkg String
-defaultFlags = Flags [] [] QuickCheck1
+defaultFlags = Flags [] []
 withPkg pkg = alterFlags $ \flags -> flags {pkgsFromFlags = pkg : pkgsFromFlags flags}
 withNdImport nd = alterFlags $ \flags -> flags {ndsImportFromFlags = nd : ndsImportFromFlags flags}
 withNdsImport nds = alterFlags $ \flags -> flags {ndsImportFromFlags = nds}
 withNdsImport' []  = withNdsImport []
 withNdsImport' nds = appEndo . mconcat . map (Endo . withNdImport) $ nds
-withPropertyTester pt = alterFlags $ \flags -> flags {propertyTester = pt}
+withPropertyTester pt = \opts -> opts {propertyTester = pt}
 
 main = fmap (foldr ($) noOptions) (getCommandLineOptions withNfOption) >>= defaultNfs >>= act >>= exitWith . exitCodeFor
   where act Options {modeFromOptions = VersionMode} = putStrLn ("hstest " ++ showVersion version) >> exitSuccess
         act Options {modeFromOptions = HelpMode} = putStrLn usageMsg >> exitSuccess
-        act opts = runGhc' opts $ runOnList ((resolvePropertyTester . propertyTester $ flagsFromOptions opts) `secretly` ensureUsingCorrectPropertyTester)
+        act opts = runGhc' opts $ runOnList ((resolvePropertyTester $ propertyTester opts) `secretly` ensureUsingCorrectPropertyTester)
                                             runModuleTests
                                             (G.liftIO . putCountLn "Total" . mconcat)
                                             (G.liftIO $ putStrLn "No Haskell source files!" >> return mempty)