packages feed

tasty-auto 0.1.0.1 → 0.1.0.2

raw patch · 4 files changed

+37/−12 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Test.Tasty.Auto: showTestDriver :: FilePath -> [Test] -> ShowS
+ Test.Tasty.Auto: showTestDriver :: [String] -> FilePath -> [Test] -> ShowS

Files

README.md view
@@ -25,6 +25,8 @@  ## Examples +### QuickCheck+ ``` haskell -- test/PropTest.hs module PropTest where@@ -33,6 +35,8 @@ prop_Addition_is_commutative a b = a + b == b + a ``` +### HUnit+ ``` haskell -- test/CaseTest.hs module CaseTest where@@ -43,6 +47,8 @@ case_List_comparison_with_different_length = [1, 2, 3] `compare` [1,2] @?= GT ``` +### Hspec+ ``` haskell -- test/TestSpec.hs module TestSpec where@@ -56,6 +62,8 @@       head [23 ..] `shouldBe` (23 :: Int) ``` +### Test trees+ ``` haskell -- test/TreeTest.hs {-# LANGUAGE ScopedTypeVariables #-}@@ -85,7 +93,16 @@   pure $ map (\s -> testCase s $ pure ()) inputs ``` -### Generated code+## Support for additional ingredients++You can add tasty ingredients with the `-optF` option:++``` haskell+-- test/test.hs+{-# OPTIONS_GHC -F -pgmF tasty-auto -optF Test.Tasty.Runners.Html.htmlRunner -optF Test.Tasty.Runners.AntXML.antXMLRunner #-}+```++## Generated code  The generated code of the preprocessor looks like this: 
src/Test/Tasty/Auto.hs view
@@ -69,8 +69,8 @@ getGenerators :: [Test] -> [Generator] getGenerators = map head . groupBy  ((==) `on` genPrefix) . sortOn genPrefix . map getGenerator -showImports :: [Test] -> ShowS-showImports = foldEndo . map (\m -> str "import qualified " . str m . nl) . nub . map testModule+showImports :: [String] -> ShowS+showImports = foldEndo . map (\m -> str "import qualified " . str m . nl) . nub  showSetup :: Test -> ShowS -> ShowS showSetup t var = str "  " . var . str " <- " . genSetup (getGenerator t) t . nl@@ -78,20 +78,28 @@ foldEndo :: (Functor f, Foldable f) => f (a -> a) -> (a -> a) foldEndo = appEndo . fold . fmap Endo -showTestDriver :: FilePath -> [Test] -> ShowS-showTestDriver src ts = let gs = getGenerators ts; vars = map (str . ("t"++) . show) [(0::Int)..] in+ingredientImport :: String -> String+ingredientImport = reverse . tail . dropWhile (/= '.') . reverse++mainFunction :: [String] -> ShowS+mainFunction [] = str "  T.defaultMain"+mainFunction ingredients = str "  T.defaultMainWithIngredients ("+  . foldEndo (map (\i -> str i . (':':)) ingredients) . str "T.defaultIngredients)"++showTestDriver :: [String] -> FilePath -> [Test] -> ShowS+showTestDriver ingredients src ts = let gs = getGenerators ts; vars = map (str . ('t':) . show) [(0::Int)..] in     str "{-# LINE 1 " . shows src . str " #-}\n\         \{-# LANGUAGE FlexibleInstances #-}\n\         \module Main where\n\         \import Prelude\n\         \import qualified Test.Tasty as T\n"   . foldEndo (map genImport gs)-  . showImports ts+  . showImports (map ingredientImport ingredients ++ map testModule ts)   . foldEndo (map genClass gs)   . str "main :: IO ()\n\         \main = do\n"   . foldEndo (zipWith showSetup ts vars)-  . str "  T.defaultMain $ T.testGroup " . shows src . str " ["+  . mainFunction ingredients . str " $ T.testGroup " . shows src . str " ["   . foldEndo (intersperse (',':) $ zipWith (curry snd) ts vars)   . str "]\n" 
tasty-auto.cabal view
@@ -3,9 +3,9 @@ -- see: https://github.com/sol/hpack  name:           tasty-auto-version:        0.1.0.1-synopsis:       Simple auto discovery for Tasty-description:    Simple auto discovery for Tasty+version:        0.1.0.2+synopsis:       Auto discovery for Tasty with support for ingredients and test tree generation+description:    Auto discovery for Tasty with support for ingredients and test tree generation category:       Testing stability:      experimental homepage:       https://github.com/minad/tasty-auto#readme
tasty-auto.hs view
@@ -7,9 +7,9 @@ main = do   args <- getArgs   case args of-    src : _ : dst : _ -> do+    src : _ : dst : ingredients -> do       tests <- findTests src-      writeFile dst $ showTestDriver src tests ""+      writeFile dst $ showTestDriver ingredients src tests ""     _ -> do       hPutStrLn stderr "tasty-auto: Expected source and destination arguments"       exitFailure