Hello community, here is the log from the commit of package ghc-tasty-th for openSUSE:Factory checked in at 2017-05-10 20:49:51 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-tasty-th (Old) and /work/SRC/openSUSE:Factory/.ghc-tasty-th.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-tasty-th" Wed May 10 20:49:51 2017 rev:3 rq:491513 version:0.1.7 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-tasty-th/ghc-tasty-th.changes 2017-04-14 13:41:35.530564777 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-tasty-th.new/ghc-tasty-th.changes 2017-05-10 20:49:52.532282774 +0200 @@ -1,0 +2,10 @@ +Wed Apr 19 13:31:54 UTC 2017 - [email protected] + +- Update to version 0.1.7 with cabal2obs. + +------------------------------------------------------------------- +Sun Apr 9 18:08:09 UTC 2017 - [email protected] + +- Update to version 0.1.6 with cabal2obs. + +------------------------------------------------------------------- Old: ---- tasty-th-0.1.5.tar.gz New: ---- tasty-th-0.1.7.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-tasty-th.spec ++++++ --- /var/tmp/diff_new_pack.Os3Mkz/_old 2017-05-10 20:49:53.312172725 +0200 +++ /var/tmp/diff_new_pack.Os3Mkz/_new 2017-05-10 20:49:53.316172160 +0200 @@ -17,8 +17,9 @@ %global pkg_name tasty-th +%bcond_with tests Name: ghc-%{pkg_name} -Version: 0.1.5 +Version: 0.1.7 Release: 0 Summary: Automatic tasty test case discovery using TH License: BSD-3-Clause @@ -31,6 +32,9 @@ BuildRequires: ghc-tasty-devel BuildRequires: ghc-template-haskell-devel BuildRoot: %{_tmppath}/%{name}-%{version}-build +%if %{with tests} +BuildRequires: ghc-tasty-hunit-devel +%endif %description Generate tasty TestTrees automatically with TemplateHaskell. See the README for @@ -56,6 +60,9 @@ %install %ghc_lib_install +%check +%cabal_test + %post devel %ghc_pkg_recache @@ -68,5 +75,6 @@ %files devel -f %{name}-devel.files %defattr(-,root,root,-) +%doc example-explicit.hs example-literate.lhs example.hs %changelog ++++++ tasty-th-0.1.5.tar.gz -> tasty-th-0.1.7.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-th-0.1.5/example-explicit.hs new/tasty-th-0.1.7/example-explicit.hs --- old/tasty-th-0.1.5/example-explicit.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/tasty-th-0.1.7/example-explicit.hs 2017-04-10 18:07:25.000000000 +0200 @@ -0,0 +1,25 @@ +{-# LANGUAGE TemplateHaskell #-} +module Main where + +import Test.Tasty +import Test.Tasty.TH +import Test.Tasty.QuickCheck +import Test.Tasty.HUnit + +main :: IO () +main = $(defaultMainGeneratorFor "explicit" ["prop_length_append", "case_length_1", "test_plus"]) + +prop_length_append :: [Int] -> [Int] -> Bool +prop_length_append as bs = length (as ++ bs) == length as + length bs + +case_length_1 :: Assertion +case_length_1 = 1 @=? length [()] + +case_add :: Assertion +case_add = 7 @=? (3 + 4) + +test_plus :: [TestTree] +test_plus = + [ $(testGroupGeneratorFor "case_add" ["case_add"]) + -- ... + ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-th-0.1.5/example-literate.lhs new/tasty-th-0.1.7/example-literate.lhs --- old/tasty-th-0.1.5/example-literate.lhs 1970-01-01 01:00:00.000000000 +0100 +++ new/tasty-th-0.1.7/example-literate.lhs 2017-04-10 18:07:25.000000000 +0200 @@ -0,0 +1,36 @@ +This is an example of using tasty-th with literate haskell files. +First, we need to import the library and enable template haskell: + +> {-# LANGUAGE TemplateHaskell #-} +> import Test.Tasty +> import Test.Tasty.TH +> import Test.Tasty.QuickCheck +> import Test.Tasty.HUnit + +Now, we can write some quickcheck properties: + +> prop_length_append :: [Int] -> [Int] -> Bool +> prop_length_append as bs = length (as ++ bs) == length as + length bs + +Or write a HUnit test case: + +> case_length_1 :: Assertion +> case_length_1 = 1 @=? length [()] + +Properties in comments are not run: + +prop_comment :: Assertion +prop_comment = assertFailure "property in comment should not be run" + +We can also create test trees: + +> test_plus :: [TestTree] +> test_plus = +> [ testCase "3 + 4" (7 @=? (3 + 4)) +> -- ... +> ] + +We only need a main now that collects all our tests: + +> main :: IO () +> main = $(defaultMainGenerator) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-th-0.1.5/example.hs new/tasty-th-0.1.7/example.hs --- old/tasty-th-0.1.5/example.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/tasty-th-0.1.7/example.hs 2017-04-10 18:07:25.000000000 +0200 @@ -0,0 +1,29 @@ +{-# LANGUAGE TemplateHaskell #-} +module Main where + +import Test.Tasty +import Test.Tasty.TH +import Test.Tasty.QuickCheck +import Test.Tasty.HUnit + +main :: IO () +main = $(defaultMainGenerator) + +{- +Properties in comments are not run: + +prop_comment :: Assertion +prop_comment = assertFailure "property in comment should not be run" +-} + +prop_length_append :: [Int] -> [Int] -> Bool +prop_length_append as bs = length (as ++ bs) == length as + length bs + +case_length_1 :: Assertion +case_length_1 = 1 @=? length [()] + +test_plus :: [TestTree] +test_plus = + [ testCase "3 + 4" (7 @=? (3 + 4)) + -- ... + ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-th-0.1.5/src/Test/Tasty/TH.hs new/tasty-th-0.1.7/src/Test/Tasty/TH.hs --- old/tasty-th-0.1.5/src/Test/Tasty/TH.hs 2017-04-01 16:08:54.000000000 +0200 +++ new/tasty-th-0.1.7/src/Test/Tasty/TH.hs 2017-04-10 18:07:25.000000000 +0200 @@ -29,12 +29,15 @@ import Control.Monad (join) import Control.Applicative -import Language.Haskell.Exts (parseFileContents) -import Language.Haskell.Exts.Parser (ParseResult(..)) +import Language.Haskell.Exts (parseFileContentsWithMode) +import Language.Haskell.Exts.Parser (ParseResult(..), defaultParseMode, parseFilename) import qualified Language.Haskell.Exts.Syntax as S import Language.Haskell.TH -import Data.List import Data.Maybe +import Data.Data (gmapQ, Data) +import Data.Typeable (cast) +import Data.List (nub, isPrefixOf, find) +import qualified Data.Foldable as F import Test.Tasty import Prelude @@ -91,13 +94,28 @@ where lexed = map fst . concatMap lex . lines - parsed file = case parseFileContents file of + parsed file = case parseFileContentsWithMode (defaultParseMode { parseFilename = filePath }) file of ParseOk parsedModule -> Just (declarations parsedModule) ParseFailed _ _ -> Nothing - declarations (S.Module _ _ _ _ decls) = mapMaybe testFunName decls + declarations (S.Module _ _ _ _ decls) = concatMap testFunName decls declarations _ = [] - testFunName (S.PatBind _ (S.PVar _ (S.Ident _ n)) _ _) = Just n - testFunName _ = Nothing + testFunName (S.PatBind _ pat _ _) = patternVariables pat + testFunName (S.FunBind _ clauses) = nub (map clauseName clauses) + testFunName _ = [] + clauseName (S.Match _ name _ _ _) = nameString name + clauseName (S.InfixMatch _ _ name _ _ _) = nameString name + +-- | Convert a 'Name' to a 'String' +nameString :: S.Name l -> String +nameString (S.Ident _ n) = n +nameString (S.Symbol _ n) = n + +-- | Find all variables that are bound in the given pattern. +patternVariables :: Data l => S.Pat l -> [String] +patternVariables = go + where + go (S.PVar _ name) = [nameString name] + go pat = concat $ gmapQ (F.foldMap go . cast) pat -- | Extract the name of the current module. locationModule :: ExpQ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-th-0.1.5/tasty-th.cabal new/tasty-th-0.1.7/tasty-th.cabal --- old/tasty-th-0.1.5/tasty-th.cabal 2017-04-01 16:08:54.000000000 +0200 +++ new/tasty-th-0.1.7/tasty-th.cabal 2017-04-10 18:07:25.000000000 +0200 @@ -1,6 +1,6 @@ name: tasty-th -version: 0.1.5 -cabal-version: >= 1.6 +version: 0.1.7 +cabal-version: >= 1.8 build-type: Simple license: BSD3 license-file: BSD3.txt @@ -11,13 +11,29 @@ category: Testing author: Oscar Finnsson & Emil Nordling & Benno Fünfstück +extra-source-files: + example.hs + example-explicit.hs + example-literate.lhs library exposed-modules: Test.Tasty.TH build-depends: base >= 4 && < 5, haskell-src-exts >= 1.18.0, tasty, template-haskell hs-source-dirs: src + ghc-options: -Wall other-extensions: TemplateHaskell +test-suite tasty-th-tests + hs-source-dirs: tests + main-is: Main.hs + build-depends: + base >= 4 && < 5, + tasty-hunit, + tasty-th + ghc-options: -Wall + default-language: Haskell2010 + type: exitcode-stdio-1.0 + source-repository head type: git location: https://github.com/bennofs/tasty-th.git diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-th-0.1.5/tests/Main.hs new/tasty-th-0.1.7/tests/Main.hs --- old/tasty-th-0.1.5/tests/Main.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/tasty-th-0.1.7/tests/Main.hs 2017-04-10 18:07:25.000000000 +0200 @@ -0,0 +1,25 @@ +{-# LANGUAGE TemplateHaskell #-} +import Test.Tasty.TH +import Test.Tasty.HUnit +import Data.List (sort) + +main :: IO () +main = $(defaultMainGenerator) + +case_example_test_functions :: Assertion +case_example_test_functions = do + functions <- extractTestFunctions "example.hs" + let expected = [ "prop_length_append", "case_length_1", "test_plus" ] + sort expected @=? sort functions + +case_example_explicit_test_functions :: Assertion +case_example_explicit_test_functions = do + functions <- extractTestFunctions "example-explicit.hs" + let expected = [ "case_add", "prop_length_append", "case_length_1", "test_plus" ] + sort expected @=? sort functions + +case_example_literate_test_functions :: Assertion +case_example_literate_test_functions = do + functions <- extractTestFunctions "example-literate.lhs" + let expected = [ "prop_length_append", "case_length_1", "test_plus" ] + sort expected @=? sort functions
