Hello community,

here is the log from the commit of package ghc-tasty-auto for openSUSE:Factory 
checked in at 2017-08-31 21:00:11
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-tasty-auto (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-tasty-auto.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-tasty-auto"

Thu Aug 31 21:00:11 2017 rev:2 rq:513508 version:0.2.0.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-tasty-auto/ghc-tasty-auto.changes    
2017-04-12 18:09:20.568272409 +0200
+++ /work/SRC/openSUSE:Factory/.ghc-tasty-auto.new/ghc-tasty-auto.changes       
2017-08-31 21:00:12.675822192 +0200
@@ -1,0 +2,5 @@
+Thu Jul 27 14:06:53 UTC 2017 - psim...@suse.com
+
+- Update to version 0.2.0.0.
+
+-------------------------------------------------------------------

Old:
----
  tasty-auto-0.1.0.2.tar.gz

New:
----
  tasty-auto-0.2.0.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-tasty-auto.spec ++++++
--- /var/tmp/diff_new_pack.TYQCOg/_old  2017-08-31 21:00:13.903649679 +0200
+++ /var/tmp/diff_new_pack.TYQCOg/_new  2017-08-31 21:00:13.907649117 +0200
@@ -19,7 +19,7 @@
 %global pkg_name tasty-auto
 %bcond_with tests
 Name:           ghc-%{pkg_name}
-Version:        0.1.0.2
+Version:        0.2.0.0
 Release:        0
 Summary:        Auto discovery for Tasty with support for ingredients and test 
tree generation
 License:        MIT

++++++ tasty-auto-0.1.0.2.tar.gz -> tasty-auto-0.2.0.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/tasty-auto-0.1.0.2/README.md 
new/tasty-auto-0.2.0.0/README.md
--- old/tasty-auto-0.1.0.2/README.md    2017-02-12 01:07:44.000000000 +0100
+++ new/tasty-auto-0.2.0.0/README.md    2017-03-04 21:07:55.000000000 +0100
@@ -93,13 +93,20 @@
   pure $ map (\s -> testCase s $ pure ()) inputs
 ```
 
-## Support for additional ingredients
+## Configuration options
 
 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 #-}
+{-# OPTIONS_GHC -F -pgmF tasty-auto -optF 
--ingredient=Test.Tasty.Runners.Html.htmlRunner -optF 
--ingredient=Test.Tasty.Runners.AntXML.antXMLRunner #-}
+```
+
+It is possible to configure the name of the generated module, if you want to 
import the module somewhere.
+
+``` haskell
+-- test/AutoTests.hs
+{-# OPTIONS_GHC -F -pgmF tasty-auto -optF --module=AutoTests #-}
 ```
 
 ## Generated code
@@ -109,9 +116,10 @@
 ``` haskell
 {-# LINE 1 "test/test.hs" #-}
 {-# LANGUAGE FlexibleInstances #-}
-module Main where
+module Main (main, ingredients, tests) where
 import Prelude
 import qualified Test.Tasty as T
+import qualified Test.Tasty.Ingredients as T
 import qualified Test.Tasty.HUnit as HU
 import qualified Test.Tasty.QuickCheck as QC
 import qualified Test.Tasty.SmallCheck as SC
@@ -131,8 +139,8 @@
 instance TestGroup [T.TestTree]      where testGroup n a = pure $ T.testGroup 
n a
 instance TestGroup (IO T.TestTree)   where testGroup _ a = a
 instance TestGroup (IO [T.TestTree]) where testGroup n a = T.testGroup n <$> a
-main :: IO ()
-main = do
+tests :: IO T.TestTree
+tests = do
   t0 <- testCase "List comparison with different length" 
CaseTest.case_List_comparison_with_different_length
   t1 <- pure $ SC.testProperty "sort reverse" SCPropTest.scprop_sort_reverse
   t2 <- testGroup "Addition" TreeTest.test_Addition
@@ -142,5 +150,9 @@
   t6 <- pure $ QC.testProperty "Addition is commutative" 
PropTest.prop_Addition_is_commutative
   t7 <- HS.testSpec "Prelude" TestSpec.spec_Prelude
   t8 <- pure $ QC.testProperty "Addition is associative" 
SubMod.PropTest.prop_Addition_is_associative
-  T.defaultMain $ T.testGroup "test/test.hs" [t0,t1,t2,t3,t4,t5,t6,t7,t8]
+  pure $ T.testGroup "test/test.hs" [t0,t1,t2,t3,t4,t5,t6,t7,t8]
+ingredients :: [T.Ingredient]
+ingredients = T.defaultIngredients
+main :: IO ()
+main = tests >>= T.defaultMainWithIngredients ingredients
 ```
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/tasty-auto-0.1.0.2/src/Test/Tasty/Auto.hs 
new/tasty-auto-0.2.0.0/src/Test/Tasty/Auto.hs
--- old/tasty-auto-0.1.0.2/src/Test/Tasty/Auto.hs       2017-02-12 
01:05:33.000000000 +0100
+++ new/tasty-auto-0.2.0.0/src/Test/Tasty/Auto.hs       2017-03-04 
21:06:44.000000000 +0100
@@ -1,7 +1,7 @@
 module Test.Tasty.Auto (findTests, showTestDriver) where
 
 import Data.Function (on)
-import Data.List (find, isPrefixOf, isSuffixOf, nub, intersperse, groupBy, 
sortOn)
+import Data.List (find, isPrefixOf, isSuffixOf, nub, intersperse, groupBy, 
sortOn, dropWhileEnd)
 import Data.Maybe (fromJust)
 import System.Directory (getDirectoryContents, doesDirectoryExist)
 import Data.Traversable (for)
@@ -79,29 +79,33 @@
 foldEndo = appEndo . fold . fmap Endo
 
 ingredientImport :: String -> String
-ingredientImport = reverse . tail . dropWhile (/= '.') . reverse
+ingredientImport = init . dropWhileEnd (/= '.')
 
-mainFunction :: [String] -> ShowS
-mainFunction [] = str "  T.defaultMain"
-mainFunction ingredients = str "  T.defaultMainWithIngredients ("
-  . foldEndo (map (\i -> str i . (':':)) ingredients) . str 
"T.defaultIngredients)"
+ingredients :: [String] -> ShowS
+ingredients is = foldEndo (map (\i -> str i . (':':)) is) . str 
"T.defaultIngredients"
 
-showTestDriver :: [String] -> FilePath -> [Test] -> ShowS
-showTestDriver ingredients src ts = let gs = getGenerators ts; vars = map (str 
. ('t':) . show) [(0::Int)..] in
+showTestDriver :: String -> [String] -> FilePath -> [Test] -> ShowS
+showTestDriver modname is 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\
+        \module " . str modname . str " (main, ingredients, tests) where\n\
         \import Prelude\n\
-        \import qualified Test.Tasty as T\n"
+        \import qualified Test.Tasty as T\n\
+        \import qualified Test.Tasty.Ingredients as T\n"
   . foldEndo (map genImport gs)
-  . showImports (map ingredientImport ingredients ++ map testModule ts)
+  . showImports (map ingredientImport is ++ map testModule ts)
   . foldEndo (map genClass gs)
-  . str "main :: IO ()\n\
-        \main = do\n"
+  . str "tests :: IO T.TestTree\n\
+        \tests = do\n"
   . foldEndo (zipWith showSetup ts vars)
-  . mainFunction ingredients . str " $ T.testGroup " . shows src . str " ["
+  . str "  pure $ T.testGroup " . shows src . str " ["
   . foldEndo (intersperse (',':) $ zipWith (curry snd) ts vars)
   . str "]\n"
+  . str "ingredients :: [T.Ingredient]\n\
+        \ingredients = " . ingredients is . str "\n\
+        \main :: IO ()\n\
+        \main = tests >>= T.defaultMainWithIngredients ingredients\n"
 
 filesBySuffix :: FilePath -> [String] -> IO [FilePath]
 filesBySuffix dir suffixes = do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/tasty-auto-0.1.0.2/tasty-auto.cabal 
new/tasty-auto-0.2.0.0/tasty-auto.cabal
--- old/tasty-auto-0.1.0.2/tasty-auto.cabal     2017-02-12 01:18:56.000000000 
+0100
+++ new/tasty-auto-0.2.0.0/tasty-auto.cabal     2017-03-04 21:10:34.000000000 
+0100
@@ -3,7 +3,7 @@
 -- see: https://github.com/sol/hpack
 
 name:           tasty-auto
-version:        0.1.0.2
+version:        0.2.0.0
 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
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/tasty-auto-0.1.0.2/tasty-auto.hs 
new/tasty-auto-0.2.0.0/tasty-auto.hs
--- old/tasty-auto-0.1.0.2/tasty-auto.hs        2017-02-12 01:09:05.000000000 
+0100
+++ new/tasty-auto-0.2.0.0/tasty-auto.hs        2017-03-04 20:59:53.000000000 
+0100
@@ -1,15 +1,29 @@
-import System.Exit (exitFailure)
+import Control.Monad (when)
+import Data.List (foldl')
+import System.Console.GetOpt (getOpt, usageInfo, ArgDescr(..), ArgOrder(..), 
OptDescr(..))
 import System.Environment (getArgs)
+import System.Exit (exitFailure)
 import System.IO (hPutStrLn, stderr)
 import Test.Tasty.Auto
 
+options :: [OptDescr ((String, [String], Bool) -> (String, [String], Bool))]
+options =
+  [ Option [] ["module"]     (ReqArg (\x (_, b, c) -> (x, b, c))        
"MODULE")     "Qualified module name"
+  , Option [] ["ingredient"] (ReqArg (\x (a, b, c) -> (a, b ++ [x], c)) 
"INGREDIENT") "Qualified ingredient name"
+  , Option [] ["debug"]      (NoArg  (\   (a, b, _) -> (a, b, True)))          
       "Debug output"
+  ]
+
 main :: IO ()
 main = do
   args <- getArgs
   case args of
-    src : _ : dst : ingredients -> do
-      tests <- findTests src
-      writeFile dst $ showTestDriver ingredients src tests ""
+    src : _ : dst : optargs
+      | (opts, [], []) <- getOpt Permute options optargs -> do
+          tests <- findTests src
+          let output = showTestDriver modname ingredients src tests ""
+              (modname, ingredients, debug) = foldl' (flip id) ("Main", [], 
False) opts
+          when debug $ hPutStrLn stderr output
+          writeFile dst output
     _ -> do
-      hPutStrLn stderr "tasty-auto: Expected source and destination arguments"
+      hPutStrLn stderr $ usageInfo "Usage: tasty-auto src _ dst [OPTION...]" 
options
       exitFailure
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/tasty-auto-0.1.0.2/test/test.hs 
new/tasty-auto-0.2.0.0/test/test.hs
--- old/tasty-auto-0.1.0.2/test/test.hs 2017-01-24 02:56:13.000000000 +0100
+++ new/tasty-auto-0.2.0.0/test/test.hs 2017-03-04 21:04:01.000000000 +0100
@@ -1 +1 @@
-{-# OPTIONS_GHC -F -pgmF tasty-auto #-}
+{-# OPTIONS_GHC -F -pgmF tasty-auto -optF --debug #-}


Reply via email to