tasty-discover 2.0.1 → 2.0.2
raw patch · 13 files changed
+279/−74 lines, 13 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +86/−0
- LICENSE +19/−0
- LICENSE.md +0/−19
- README.md +113/−0
- executable/Main.hs +7/−7
- library/Test/Tasty/Config.hs +4/−3
- library/Test/Tasty/Discover.hs +9/−8
- library/Test/Tasty/Generator.hs +8/−8
- tasty-discover.cabal +8/−4
- test/ConfigTest.hs +8/−8
- test/DiscoverTest.hs +13/−13
- test/SubMod/FooBaz.hs +2/−2
- test/SubMod/PropTest.hs +2/−2
+ CHANGELOG.md view
@@ -0,0 +1,86 @@+# Change Log++All notable changes to this project will be documented in this file.++The format is based on [Keep a Changelog] and this project adheres to+[Semantic Versioning].++[Keep a Changelog]: http://keepachangelog.com/+[Semantic Versioning]: http://semver.org/++# 2.0.2 [2017-04-13]++### Added+- Change log is in `extra-source-files` now.+- [#96]: README is in `extra-source-files` now.++### Fixed+- [#88]: stylish-haskell automated checking.++[#88]: https://github.com/lwm/tasty-discover/pull/88+[#96]: https://github.com/lwm/tasty-discover/pull/96++## 2.0.1 [2017-03-18]++### Fixed+- [#86]: Flaky test comparison.++[#86]: https://github.com/lwm/tasty-discover/pull/86++### Removed+- [#83]: The `Test.Tasty.Type` module.++[#83]: https://github.com/lwm/tasty-discover/pull/83++## 2.0.0 [2017-03-15]++### Added+- Use hpack format.+- Use generator style test discovery from tasty-auto.+- New configuration options: debug, ingredients and module name.+- Unit tests for all functionality.++### Fixed+- Re-license to MIT.++### Removed+- RTD documentation.+- TemplateHaskell dependency+- Example project and integration test project.++### Changed+- Move all tests into test folder.++## 1.1.0 [2017-01-19]++### Added+- `--ignore-module` configuration option.++## 1.0.1 [2017-11-13]++### Added+- Cabal testing on Travis CI.+- Documentation testing on Travis CI.++### Fixed+- Include missing `extra-source-files`.+- Slim down LICENSE.md and mark as GPL-3 in Cabal file.++## 1.0.0 [2016-11-04]++### Added+- Documentation to RTD.+- Release on Hackage and Stackage.++## 0.0.3 [2016-09-20]++### Added+- `--no-module-suffix` configuration option.++## 0.0.2 [2016-02-20]++### Added+- `--module-suffix` configuration option.++## 0.0.1 [2016-02-13]+- tasty-discover initial release.
+ LICENSE view
@@ -0,0 +1,19 @@+Copyright (c) 2016 Luke Murphy++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.
− LICENSE.md
@@ -1,19 +0,0 @@-Copyright (c) 2016 Luke Murphy--Permission is hereby granted, free of charge, to any person obtaining a copy-of this software and associated documentation files (the "Software"), to deal-in the Software without restriction, including without limitation the rights-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell-copies of the Software, and to permit persons to whom the Software is-furnished to do so, subject to the following conditions:--The above copyright notice and this permission notice shall be included in all-copies or substantial portions of the Software.--THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE-SOFTWARE.
+ README.md view
@@ -0,0 +1,113 @@+[](https://travis-ci.org/lwm/tasty-discover)+[](http://hackage.haskell.org/package/tasty-discover)+[](https://www.stackage.org/package/tasty-discover/)+[](https://raw.githubusercontent.com/lwm/tasty-discover/master/LICENSE)++# tasty-discover++Automatic test discovery and runner for the [tasty framework].++[tasty framework]: https://github.com/feuerbach/tasty++# Getting Started++++5 steps to tasty test discovery satori:+ - Create a `Tasty.hs` in the `hs-source-dirs` of your test suite.+ - Set your test suite `main-is` to the `Tasty.hs`.+ - Create test modules in files with suffix `*Test.hs` or `*Spec.hs`.+ - Write your tests with the following prefixes:+ - `prop_`: [QuickCheck](http://hackage.haskell.org/package/tasty-quickcheck) properties.+ - `scprop_`: [SmallCheck](http://hackage.haskell.org/package/tasty-smallcheck) properties.+ - `case_`: [HUnit](http://hackage.haskell.org/package/tasty-hunit) test cases.+ - `spec_`: [Hspec](http://hackage.haskell.org/package/tasty-hspec) specifications.+ - `test_`: [Tasty](http://hackage.haskell.org/package/tasty) TestTrees.++# Examples++``` haskell+{-# LANGUAGE ScopedTypeVariables #-}++module ExampleTest where++import Test.Tasty+import Test.Tasty.HUnit+import Test.Tasty.Hspec+import Test.Tasty.QuickCheck++-- HUnit test case+case_listCompare :: IO ()+case_listCompare = [1, 2, 3] `compare` [1,2] @?= GT++-- QuickCheck property+prop_additionCommutative :: Int -> Int -> Bool+prop_additionCommutative a b = a + b == b + a++-- SmallSheck property+scprop_sortReverse :: [Int] -> Bool+scprop_sortReverse list = sort list == sort (reverse list)++-- Hspec specification+spec_prelude :: Spec+spec_prelude = do+ describe "Prelude.head" $ do+ it "returns the first element of a list" $ do+ head [23 ..] `shouldBe` (23 :: Int)++-- Tasty TestTree+test_multiplication :: [TestTree]+test_multiplication = [testProperty "One is identity" $ \(a :: Int) -> a * 1 == a]++-- Tasty IO TestTree+test_generateTree :: IO TestTree+test_generateTree = do+ input <- pure "Some input"+ pure $ testCase input $ pure ()++-- Tasty IO [TestTree]+test_generateTrees :: IO [TestTree]+test_generateTrees = do+ inputs <- pure ["First input", "Second input"]+ pure $ map (\s -> testCase s $ pure ()) inputs+```++# Configuration++Pass configuration options within your `Tasty.hs` like so:++``` haskell+{-#+ OPTIONS_GHC -F -pgmF tasty-discover+ -optF <OPTION>+ -optF <OPTION>+#-}+```++## No Arguments+Example: `{-# OPTIONS_GHC -F -pgmF tasty-discover -optF --debug #-}`++ - `--no-module-suffix`: Collect all test modules, regardless of module suffix.+ - `--debug`: Output the contents of the generated module while testing.++## With Arguments+Example: `{-# OPTIONS_GHC -F -pgmF tasty-discover -optF --moduleSuffix=FooBar #-}`++ - `--module-suffix`: Which test module suffix you wish to have discovered.+ - `--generated-module`: The name of the generated test module.+ - `--ignore-module`: Which test modules to ignore from discovery.+ - `--ingredient`: Tasty ingredients to add to your test runner.++# Change Log+See the [Change log] for the latest changes.++[Change log]: https://github.com/lwm/tasty-discover/blob/master/CHANGELOG.md++# Contributing+All contributions welcome!++# Acknowledgements+Thanks to [hspec-discover] and [tasty-auto] for making this possible.++[hspec-discover]: https://hspec.github.io/hspec-discover.html+[tasty-auto]: https://github.com/minad/tasty-auto
executable/Main.hs view
@@ -1,13 +1,13 @@ -- | Main executable module. module Main where -import Control.Monad (when)-import Data.Maybe (fromMaybe)-import Test.Tasty.Config (Config(..), parseConfig)-import Test.Tasty.Discover (findTests, generateTestDriver)-import System.Environment (getArgs, getProgName)-import System.Exit (exitFailure)-import System.IO (hPutStrLn, stderr)+import Control.Monad (when)+import Data.Maybe (fromMaybe)+import System.Environment (getArgs, getProgName)+import System.Exit (exitFailure)+import System.IO (hPutStrLn, stderr)+import Test.Tasty.Config (Config (..), parseConfig)+import Test.Tasty.Discover (findTests, generateTestDriver) -- | Main function. main :: IO ()
library/Test/Tasty/Config.hs view
@@ -5,9 +5,10 @@ , defaultConfig ) where -import System.Console.GetOpt (ArgDescr(ReqArg, NoArg) , OptDescr(Option),- ArgOrder(Permute), getOpt)-import Data.Maybe (isJust)+import Data.Maybe (isJust)+import System.Console.GetOpt (ArgDescr (NoArg, ReqArg),+ ArgOrder (Permute), OptDescr (Option),+ getOpt) type Ingredient = String
library/Test/Tasty/Discover.hs view
@@ -1,13 +1,14 @@ -- | Automatic test discovery and runner for the tasty framework. module Test.Tasty.Discover where -import Data.List (isPrefixOf, isSuffixOf, nub, intercalate, dropWhileEnd)-import System.Directory (getDirectoryContents, doesDirectoryExist)-import Data.Traversable (for)-import System.FilePath ((</>), takeDirectory)-import Test.Tasty.Generator (Generator(..), Test(..), mkTest,- generators, showSetup, getGenerators)-import Test.Tasty.Config (Config(..))+import Data.List (dropWhileEnd, intercalate, isPrefixOf,+ isSuffixOf, nub)+import Data.Traversable (for)+import System.Directory (doesDirectoryExist, getDirectoryContents)+import System.FilePath (takeDirectory, (</>))+import Test.Tasty.Config (Config (..))+import Test.Tasty.Generator (Generator (..), Test (..), generators,+ getGenerators, mkTest, showSetup) generateTestDriver :: String -> [String] -> FilePath -> [Test] -> String generateTestDriver modname is src tests =@@ -86,7 +87,7 @@ where suffixes = case suffix of Just suffix' -> [suffix']- Nothing -> ["Spec", "Test"]+ Nothing -> ["Spec", "Test"] showImports :: [String] -> String showImports mods = unlines $ nub $ map (\m -> "import qualified " ++ m ++ "\n") mods
library/Test/Tasty/Generator.hs view
@@ -8,10 +8,10 @@ , mkTest, ) where -import Data.List (find, isPrefixOf, groupBy, sortOn)-import Data.Function (on)-import Data.Maybe (fromJust)-import System.FilePath (pathSeparator, dropExtension)+import Data.Function (on)+import Data.List (find, groupBy, isPrefixOf, sortOn)+import Data.Maybe (fromJust)+import System.FilePath (dropExtension, pathSeparator) data Test = Test { testModule :: String@@ -23,10 +23,10 @@ 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+ { generatorPrefix :: String+ , generatorImport :: String+ , generatorClass :: String+ , generatorSetup :: Test -> String } qualifyFunction :: Test -> String
tasty-discover.cabal view
@@ -3,20 +3,24 @@ -- see: https://github.com/sol/hpack name: tasty-discover-version: 2.0.1+version: 2.0.2 synopsis: Test discovery for the tasty framework.-description: Test discovery for the tasty framework.+description: Prefix your test case names and tasty-discover will discover, collect and run them. All popular test libraries are covered. Configure once and then just write your tests. Avoid forgetting to add test modules to your Cabal/Hpack files. Tasty ingredients are included along with various configuration options for different use cases. Please see the `README.md` below for how to get started. category: Testing stability: Experimental homepage: https://github.com/lwm/tasty-discover#readme bug-reports: https://github.com/lwm/tasty-discover/issues-author: Luke Murphy <lukewm@riseup.net>+author: Luke Murphy maintainer: Luke Murphy <lukewm@riseup.net> copyright: 2016 Luke Murphy license: MIT-license-file: LICENSE.md+license-file: LICENSE build-type: Simple cabal-version: >= 1.10++extra-source-files:+ CHANGELOG.md+ README.md source-repository head type: git
test/ConfigTest.hs view
@@ -1,10 +1,10 @@ module ConfigTest where -import Data.List (isInfixOf)-import Test.Tasty.Discover (findTests, generateTestDriver)-import Test.Tasty.HUnit-import Test.Tasty.Config-import Test.Tasty.Generator (mkTest)+import Data.List (isInfixOf)+import Test.Tasty.Config+import Test.Tasty.Discover (findTests, generateTestDriver)+import Test.Tasty.Generator (mkTest)+import Test.Tasty.HUnit case_noModuleSuffixEmptyList :: IO () case_noModuleSuffixEmptyList = do@@ -23,9 +23,9 @@ case_noModuleSuffix :: IO () case_noModuleSuffix = do actual1 <- findTests "test/SubMod/" defaultConfig- actual1 @?= [mkTest "PropTest" "prop_addition_is_associative"]+ actual1 @?= [mkTest "PropTest" "prop_additionAssociative"] actual2 <- findTests "test/SubMod/" (defaultConfig { noModuleSuffix = True })- let expected = [ mkTest "FooBaz" "prop_addition_is_commutative"- , mkTest "PropTest" "prop_addition_is_associative" ]+ let expected = [ mkTest "FooBaz" "prop_additionCommutative"+ , mkTest "PropTest" "prop_additionAssociative" ] assertBool "" $ all (`elem` expected) actual2
test/DiscoverTest.hs view
@@ -2,17 +2,17 @@ module DiscoverTest where -import Data.List-import Test.Tasty-import Test.Tasty.HUnit-import Test.Tasty.Hspec-import Test.Tasty.QuickCheck+import Data.List+import Test.Tasty+import Test.Tasty.Hspec+import Test.Tasty.HUnit+import Test.Tasty.QuickCheck -case_list_comparison_with_different_length :: IO ()-case_list_comparison_with_different_length = [1 :: Int, 2, 3] `compare` [1,2] @?= GT+case_listCompare :: IO ()+case_listCompare = [1 :: Int, 2, 3] `compare` [1,2] @?= GT -prop_addition_is_commutative :: Int -> Int -> Bool-prop_addition_is_commutative a b = a + b == b + a+prop_additionCommutative :: Int -> Int -> Bool+prop_additionCommutative a b = a + b == b + a scprop_sortReverse :: [Int] -> Bool scprop_sortReverse list = sort list == sort (reverse list)@@ -32,12 +32,12 @@ , testProperty "One is identity" $ \(a :: Int) -> a == a ] -test_generate_tree :: IO TestTree-test_generate_tree = do+test_generateTree :: IO TestTree+test_generateTree = do input <- pure "Some input" pure $ testCase input $ pure () -test_generate_Trees :: IO [TestTree]-test_generate_Trees = do+test_generateTrees :: IO [TestTree]+test_generateTrees = do inputs <- pure ["First input", "Second input"] pure $ map (\s -> testCase s $ pure ()) inputs
test/SubMod/FooBaz.hs view
@@ -1,4 +1,4 @@ module SubMod.FooBaz where -prop_addition_is_commutative :: Int -> Int -> Bool-prop_addition_is_commutative a b = a + b == b + a+prop_additionCommutative :: Int -> Int -> Bool+prop_additionCommutative a b = a + b == b + a
test/SubMod/PropTest.hs view
@@ -1,4 +1,4 @@ module SubMod.PropTest where -prop_addition_is_associative :: Int -> Int -> Int -> Bool-prop_addition_is_associative a b c = (a + b) + c == a + (b + c)+prop_additionAssociative :: Int -> Int -> Int -> Bool+prop_additionAssociative a b c = (a + b) + c == a + (b + c)