tasty-discover 2.0.0 → 2.0.1
raw patch · 8 files changed
+54/−74 lines, 8 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Test.Tasty.Type: Config :: Maybe String -> Maybe String -> [FilePath] -> [Ingredient] -> Bool -> Bool -> Config
- Test.Tasty.Type: Generator :: String -> String -> String -> (Test -> String) -> Generator
- Test.Tasty.Type: Test :: String -> String -> Test
- Test.Tasty.Type: [debug] :: Config -> Bool
- Test.Tasty.Type: [generatedModuleName] :: Config -> Maybe String
- Test.Tasty.Type: [generatorClass] :: Generator -> String
- Test.Tasty.Type: [generatorImport] :: Generator -> String
- Test.Tasty.Type: [generatorPrefix] :: Generator -> String
- Test.Tasty.Type: [generatorSetup] :: Generator -> Test -> String
- Test.Tasty.Type: [ignoredModules] :: Config -> [FilePath]
- Test.Tasty.Type: [moduleSuffix] :: Config -> Maybe String
- Test.Tasty.Type: [noModuleSuffix] :: Config -> Bool
- Test.Tasty.Type: [tastyIngredients] :: Config -> [Ingredient]
- Test.Tasty.Type: [testFunction] :: Test -> String
- Test.Tasty.Type: [testModule] :: Test -> String
- Test.Tasty.Type: data Config
- Test.Tasty.Type: data Generator
- Test.Tasty.Type: data Test
- Test.Tasty.Type: instance GHC.Classes.Eq Test.Tasty.Type.Test
- Test.Tasty.Type: instance GHC.Show.Show Test.Tasty.Type.Config
- Test.Tasty.Type: instance GHC.Show.Show Test.Tasty.Type.Generator
- Test.Tasty.Type: instance GHC.Show.Show Test.Tasty.Type.Test
- Test.Tasty.Type: mkTest :: FilePath -> String -> Test
+ Test.Tasty.Config: Config :: Maybe String -> Maybe String -> [FilePath] -> [Ingredient] -> Bool -> Bool -> Config
+ Test.Tasty.Config: [debug] :: Config -> Bool
+ Test.Tasty.Config: [generatedModuleName] :: Config -> Maybe String
+ Test.Tasty.Config: [ignoredModules] :: Config -> [FilePath]
+ Test.Tasty.Config: [moduleSuffix] :: Config -> Maybe String
+ Test.Tasty.Config: [noModuleSuffix] :: Config -> Bool
+ Test.Tasty.Config: [tastyIngredients] :: Config -> [Ingredient]
+ Test.Tasty.Config: data Config
+ Test.Tasty.Config: instance GHC.Show.Show Test.Tasty.Config.Config
+ Test.Tasty.Generator: Generator :: String -> String -> String -> (Test -> String) -> Generator
+ Test.Tasty.Generator: Test :: String -> String -> Test
+ Test.Tasty.Generator: [generatorClass] :: Generator -> String
+ Test.Tasty.Generator: [generatorImport] :: Generator -> String
+ Test.Tasty.Generator: [generatorPrefix] :: Generator -> String
+ Test.Tasty.Generator: [generatorSetup] :: Generator -> Test -> String
+ Test.Tasty.Generator: [testFunction] :: Test -> String
+ Test.Tasty.Generator: [testModule] :: Test -> String
+ Test.Tasty.Generator: data Generator
+ Test.Tasty.Generator: data Test
+ Test.Tasty.Generator: instance GHC.Classes.Eq Test.Tasty.Generator.Test
+ Test.Tasty.Generator: instance GHC.Show.Show Test.Tasty.Generator.Test
+ Test.Tasty.Generator: mkTest :: FilePath -> String -> Test
Files
- executable/Main.hs +1/−2
- library/Test/Tasty/Config.hs +16/−2
- library/Test/Tasty/Discover.hs +3/−2
- library/Test/Tasty/Generator.hs +21/−2
- library/Test/Tasty/Type.hs +0/−46
- tasty-discover.cabal +1/−2
- test/ConfigTest.hs +11/−17
- test/SubMod/FooBaz.hs +1/−1
executable/Main.hs view
@@ -3,9 +3,8 @@ import Control.Monad (when) import Data.Maybe (fromMaybe)-import Test.Tasty.Config (parseConfig)+import Test.Tasty.Config (Config(..), parseConfig) import Test.Tasty.Discover (findTests, generateTestDriver)-import Test.Tasty.Type (Config(..)) import System.Environment (getArgs, getProgName) import System.Exit (exitFailure) import System.IO (hPutStrLn, stderr)
library/Test/Tasty/Config.hs view
@@ -1,10 +1,24 @@ -- Configuration options module.-module Test.Tasty.Config (parseConfig, defaultConfig) where+module Test.Tasty.Config+ ( Config(..)+ , parseConfig+ , defaultConfig+ ) where import System.Console.GetOpt (ArgDescr(ReqArg, NoArg) , OptDescr(Option), ArgOrder(Permute), getOpt) import Data.Maybe (isJust)-import Test.Tasty.Type (Config(..))++type Ingredient = String++data Config = Config+ { moduleSuffix :: Maybe String+ , generatedModuleName :: Maybe String+ , ignoredModules :: [FilePath]+ , tastyIngredients :: [Ingredient]+ , noModuleSuffix :: Bool+ , debug :: Bool+ } deriving (Show) -- | The default configuration defaultConfig :: Config
library/Test/Tasty/Discover.hs view
@@ -5,8 +5,9 @@ import System.Directory (getDirectoryContents, doesDirectoryExist) import Data.Traversable (for) import System.FilePath ((</>), takeDirectory)-import Test.Tasty.Generator (generators, showSetup, getGenerators)-import Test.Tasty.Type (Config(..), Generator(..), Test(..), mkTest)+import Test.Tasty.Generator (Generator(..), Test(..), mkTest,+ generators, showSetup, getGenerators)+import Test.Tasty.Config (Config(..)) generateTestDriver :: String -> [String] -> FilePath -> [Test] -> String generateTestDriver modname is src tests =
library/Test/Tasty/Generator.hs view
@@ -1,14 +1,33 @@ module Test.Tasty.Generator- ( generators+ ( Generator(..)+ , generators , showSetup , getGenerator , getGenerators+ , Test(..)+ , mkTest, ) where -import Test.Tasty.Type (Test(..), Generator(..)) import Data.List (find, isPrefixOf, groupBy, sortOn) import Data.Function (on) import Data.Maybe (fromJust)+import System.FilePath (pathSeparator, dropExtension)++data Test = Test+ { testModule :: String+ , testFunction :: String+ } deriving (Eq, Show)++mkTest :: FilePath -> String -> Test+mkTest = Test . chooser pathSeparator '.' . dropExtension+ where chooser c1 c2 = map $ \c3 -> if c3 == c1 then c2 else c3++data Generator = Generator+ { generatorPrefix :: String+ , generatorImport :: String+ , generatorClass :: String+ , generatorSetup :: Test -> String+ } qualifyFunction :: Test -> String qualifyFunction t = testModule t ++ "." ++ testFunction t
− library/Test/Tasty/Type.hs
@@ -1,46 +0,0 @@-module Test.Tasty.Type- ( Test(..)- , mkTest- , Generator(..)- , Config(..)- ) where--import System.FilePath (pathSeparator, dropExtension)--data Test = Test- { testModule :: String- , testFunction :: String- } deriving Show--instance Eq Test where- t1 == t2 = testModule t1 == testModule t2 && testFunction t1 == testFunction t2--mkTest :: FilePath -> String -> Test-mkTest = Test . chooser pathSeparator '.' . dropExtension- where chooser c1 c2 = map $ \c3 -> if c3 == c1 then c2 else c3--data Generator = Generator- { generatorPrefix :: String- , generatorImport :: String- , generatorClass :: String- , generatorSetup :: Test -> String- }--instance Show Generator where- show generator = concat- [ generatorPrefix generator- , generatorImport generator- , generatorClass generator- , "<function:generatorSetup :: Test -> String>"- ]--type Ingredient = String--data Config = Config- { moduleSuffix :: Maybe String- , generatedModuleName :: Maybe String- , ignoredModules :: [FilePath]- , tastyIngredients :: [Ingredient]- , noModuleSuffix :: Bool- , debug :: Bool- } deriving (Show)
tasty-discover.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack name: tasty-discover-version: 2.0.0+version: 2.0.1 synopsis: Test discovery for the tasty framework. description: Test discovery for the tasty framework. category: Testing@@ -34,7 +34,6 @@ Test.Tasty.Config Test.Tasty.Discover Test.Tasty.Generator- Test.Tasty.Type default-language: Haskell2010 executable tasty-discover
test/ConfigTest.hs view
@@ -3,35 +3,29 @@ import Data.List (isInfixOf) import Test.Tasty.Discover (findTests, generateTestDriver) import Test.Tasty.HUnit-import Test.Tasty.Type+import Test.Tasty.Config+import Test.Tasty.Generator (mkTest) case_noModuleSuffixEmptyList :: IO () case_noModuleSuffixEmptyList = do- actual <- findTests "test/SubMod/" config+ actual <- findTests "test/SubMod/" (defaultConfig { moduleSuffix = Just "DoesntExist"}) actual @?= []- where- config = Config (Just "DoesntExist") Nothing [] [] False False case_differentGeneratedModule :: Assertion-case_differentGeneratedModule = assertBool "Specified module is used" test- where test = "FunkyModuleName" `isInfixOf` generatedModule- generatedModule = generateTestDriver "FunkyModuleName" [] "test/" []+case_differentGeneratedModule = assertBool "" ("FunkyModuleName" `isInfixOf` generatedModule)+ where generatedModule = generateTestDriver "FunkyModuleName" [] "test/" [] case_ignoreAModule :: IO () case_ignoreAModule = do- actual <- findTests "test/SubMod/" config+ actual <- findTests "test/SubMod/" (defaultConfig { ignoredModules = ["PropTest"] }) actual @?= []- where- config = Config Nothing Nothing ["PropTest"] [] False False case_noModuleSuffix :: IO () case_noModuleSuffix = do- actual1 <- findTests "test/SubMod/" config1+ actual1 <- findTests "test/SubMod/" defaultConfig actual1 @?= [mkTest "PropTest" "prop_addition_is_associative"] - actual2 <- findTests "test/SubMod/" config2- actual2 @?= [ mkTest "FooBaz" "prop_addition_is_commutative"- , mkTest "PropTest" "prop_addition_is_associative" ]- where- config1 = Config Nothing Nothing [] [] False False- config2 = Config Nothing Nothing [] [] True False+ actual2 <- findTests "test/SubMod/" (defaultConfig { noModuleSuffix = True })+ let expected = [ mkTest "FooBaz" "prop_addition_is_commutative"+ , mkTest "PropTest" "prop_addition_is_associative" ]+ assertBool "" $ all (`elem` expected) actual2
test/SubMod/FooBaz.hs view
@@ -1,4 +1,4 @@-module FooBaz where+module SubMod.FooBaz where prop_addition_is_commutative :: Int -> Int -> Bool prop_addition_is_commutative a b = a + b == b + a