commit ghc-tasty-discover for openSUSE:Factory
Hello community, here is the log from the commit of package ghc-tasty-discover for openSUSE:Factory checked in at 2017-08-31 21:00:16 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-tasty-discover (Old) and /work/SRC/openSUSE:Factory/.ghc-tasty-discover.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "ghc-tasty-discover" Thu Aug 31 21:00:16 2017 rev:2 rq:513510 version:3.0.2 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-tasty-discover/ghc-tasty-discover.changes 2017-05-10 20:54:35.276384429 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-tasty-discover.new/ghc-tasty-discover.changes 2017-08-31 21:00:19.714833193 +0200 @@ -1,0 +2,5 @@ +Thu Jul 27 14:05:55 UTC 2017 - psimons@suse.com + +- Update to version 3.0.2. + +------------------------------------------------------------------- Old: ---- tasty-discover-1.1.0.tar.gz New: ---- tasty-discover-3.0.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-tasty-discover.spec ++++++ --- /var/tmp/diff_new_pack.Nd1vDU/_old 2017-08-31 21:00:21.042646632 +0200 +++ /var/tmp/diff_new_pack.Nd1vDU/_new 2017-08-31 21:00:21.058644385 +0200 @@ -17,28 +17,37 @@ %global pkg_name tasty-discover +%bcond_with tests Name: ghc-%{pkg_name} -Version: 1.1.0 +Version: 3.0.2 Release: 0 Summary: Test discovery for the tasty framework -License: GPL-3.0+ +License: MIT Group: Development/Languages/Other Url: https://hackage.haskell.org/package/%{pkg_name} Source0: https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz BuildRequires: chrpath BuildRequires: ghc-Cabal-devel +BuildRequires: ghc-containers-devel BuildRequires: ghc-directory-devel BuildRequires: ghc-filepath-devel BuildRequires: ghc-rpm-macros +BuildRoot: %{_tmppath}/%{name}-%{version}-build +%if %{with tests} BuildRequires: ghc-tasty-devel BuildRequires: ghc-tasty-hspec-devel BuildRequires: ghc-tasty-hunit-devel BuildRequires: ghc-tasty-quickcheck-devel -BuildRequires: ghc-tasty-th-devel -BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildRequires: ghc-tasty-smallcheck-devel +%endif %description -Test discovery for the tasty framework. +Automatic test discovery and runner for the tasty framework. 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. %package devel Summary: Haskell %{pkg_name} library development files @@ -61,6 +70,9 @@ %ghc_lib_install %ghc_fix_rpath %{pkg_name}-%{version} +%check +%cabal_test + %post devel %ghc_pkg_recache @@ -69,11 +81,11 @@ %files -f %{name}.files %defattr(-,root,root,-) -%doc LICENSE.md +%doc LICENSE %{_bindir}/%{pkg_name} %files devel -f %{name}-devel.files %defattr(-,root,root,-) -%doc example +%doc CHANGELOG.md README.md %changelog ++++++ tasty-discover-1.1.0.tar.gz -> tasty-discover-3.0.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/CHANGELOG.md new/tasty-discover-3.0.2/CHANGELOG.md --- old/tasty-discover-1.1.0/CHANGELOG.md 1970-01-01 01:00:00.000000000 +0100 +++ new/tasty-discover-3.0.2/CHANGELOG.md 2017-06-04 10:19:21.000000000 +0200 @@ -0,0 +1,123 @@ +# 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/ + +# 3.0.2 [2017-06-05] + +### Fixed +- Make upper bounds for dependencies looser. +- Fix typo in README.md option documentation. + +### Remove +- Remove TOC, the hyperlinks weren't working on Hackage. + +# 3.0.1 [2017-06-04] + +### Fixed +- Fixed CHANGELOG.md rendering for Hackage (see pull request [#106]). + +### Added +- Add missing --tree-display documentation note (see pull request [#107]). + +[#107]: https://github.com/lwm/tasty-discover/pull/107 +[#106]: https://github.com/lwm/tasty-discover/pull/106 + +# 3.0.0 [2017-06-03] + +### Added +- Add --tree-display configuration option (see pull request [#103]). + +### Changed +- Deprecate `case_` in favour of `unit_` for HUnit test cases (see pull request [#97]). + +### Fixed +- Correctly handle sub-directories when using --no-module-suffix (see pull request [#102]). + +[#97]: https://github.com/lwm/tasty-discover/pull/97 +[#102]: https://github.com/lwm/tasty-discover/pull/102 +[#103]: https://github.com/lwm/tasty-discover/pull/103 + +# 2.0.3 [2017-04-13] + +### Fixed +- Make the Cabal description more clear for Hackage. + +# 2.0.2 [2017-04-13] + +### Added +- README.md and CHANGELOG.md included for Hackage (see pull request [#96]). +- Re-add stylish-haskell automated checking (see pull request [#88]). + +[#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 +- Fix flaky test comparison (see pull request [#86]). + +[#86]: https://github.com/lwm/tasty-discover/pull/86 + +### Removed +- Remove the Test.Tasty.Type module (see pull request [#83]). + +[#83]: https://github.com/lwm/tasty-discover/pull/83 + +## 2.0.0 [2017-03-15] + +### Added +- Add new hpack format. +- Add generator style test discovery from tasty-auto. +- Add new configuration options: debug, ingredients and module name. +- Add 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 +- Add --ignore-module configuration option. + +## 1.0.1 [2017-11-13] + +### Added +- Add Cabal and 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 +- Add documentation on 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. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/LICENSE new/tasty-discover-3.0.2/LICENSE --- old/tasty-discover-1.1.0/LICENSE 1970-01-01 01:00:00.000000000 +0100 +++ new/tasty-discover-3.0.2/LICENSE 2017-03-10 23:54:01.000000000 +0100 @@ -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. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/LICENSE.md new/tasty-discover-3.0.2/LICENSE.md --- old/tasty-discover-1.1.0/LICENSE.md 2016-11-13 23:58:50.000000000 +0100 +++ new/tasty-discover-3.0.2/LICENSE.md 1970-01-01 01:00:00.000000000 +0100 @@ -1,12 +0,0 @@ -tasty-discover - Test discovery for the tasty framework. -Copyright (C) 2017 Luke Murphy <lukewm@riseup.net> - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/README.md new/tasty-discover-3.0.2/README.md --- old/tasty-discover-1.1.0/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/tasty-discover-3.0.2/README.md 2017-06-04 02:03:59.000000000 +0200 @@ -0,0 +1,113 @@ +[![Build Status](https://travis-ci.org/lwm/tasty-discover.svg?branch=master)](https://travis-ci.org/lwm/tasty-discover) +[![Hackage Status](https://img.shields.io/hackage/v/tasty-discover.svg)](http://hackage.haskell.org/package/tasty-discover) +[![tasty-discover](http://stackage.org/package/tasty-discover/badge/nightly)](http://stackage.org/nightly/package/tasty-discover) +[![GitHub license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](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. + - `unit_`: [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 +unit_listCompare :: IO () +unit_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> + -- etc. +#-} +``` + +## 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. + - `--tree-display`: Display the test output results hierarchically. + +## With Arguments +Example: `{-# OPTIONS_GHC -F -pgmF tasty-discover -optF --module-suffix=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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/Setup.hs new/tasty-discover-3.0.2/Setup.hs --- old/tasty-discover-1.1.0/Setup.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/tasty-discover-3.0.2/Setup.hs 2017-03-11 00:56:09.000000000 +0100 @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/Setup.lhs new/tasty-discover-3.0.2/Setup.lhs --- old/tasty-discover-1.1.0/Setup.lhs 2016-11-12 18:23:30.000000000 +0100 +++ new/tasty-discover-3.0.2/Setup.lhs 1970-01-01 01:00:00.000000000 +0100 @@ -1,3 +0,0 @@ -#!/usr/bin/env runhaskell -> import Distribution.Simple -> main = defaultMain diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/example/test/AllTheFolders/AnotherNestTest.hs new/tasty-discover-3.0.2/example/test/AllTheFolders/AnotherNestTest.hs --- old/tasty-discover-1.1.0/example/test/AllTheFolders/AnotherNestTest.hs 2016-09-27 00:48:35.000000000 +0200 +++ new/tasty-discover-3.0.2/example/test/AllTheFolders/AnotherNestTest.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,4 +0,0 @@ -module AllTheFolders.AnotherNestTest where - -prop_nineIsNine :: Bool -prop_nineIsNine = 9 == (9 :: Integer) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/example/test/BarTest.hs new/tasty-discover-3.0.2/example/test/BarTest.hs --- old/tasty-discover-1.1.0/example/test/BarTest.hs 2016-10-25 02:06:18.000000000 +0200 +++ new/tasty-discover-3.0.2/example/test/BarTest.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,8 +0,0 @@ -module BarTest where - -import Test.Tasty.Discover (hspec, describe, it, shouldBe) - -case_headIsWorking = hspec $ - describe "Check if Prelude.head 'still has it'" $ - it "returns the first element of a list" $ - head [23 ..] `shouldBe` (23 :: Int) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/example/test/FooTest.hs new/tasty-discover-3.0.2/example/test/FooTest.hs --- old/tasty-discover-1.1.0/example/test/FooTest.hs 2016-09-27 00:48:35.000000000 +0200 +++ new/tasty-discover-3.0.2/example/test/FooTest.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,15 +0,0 @@ -module FooTest where - -import Test.Tasty.Discover (Assertion, (@?=), TestTree, testCase) - -test_allMyTestsGrouped :: [TestTree] -test_allMyTestsGrouped = - [ testCase "Testing the meaning of life." case_theAnswer - , testCase "Testing the number of the beast." case_theNumberOfTheBeast - ] - -case_theAnswer :: Assertion -case_theAnswer = 42 @?= (42 :: Integer) - -case_theNumberOfTheBeast :: Assertion -case_theNumberOfTheBeast = 666 @?= (666 :: Integer) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/example/test/Tasty.hs new/tasty-discover-3.0.2/example/test/Tasty.hs --- old/tasty-discover-1.1.0/example/test/Tasty.hs 2016-09-27 00:48:35.000000000 +0200 +++ new/tasty-discover-3.0.2/example/test/Tasty.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -{-# OPTIONS_GHC -F -pgmF tasty-discover #-} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/example/test/Thing/AnotherThing/NestedTest.hs new/tasty-discover-3.0.2/example/test/Thing/AnotherThing/NestedTest.hs --- old/tasty-discover-1.1.0/example/test/Thing/AnotherThing/NestedTest.hs 2016-09-27 00:48:35.000000000 +0200 +++ new/tasty-discover-3.0.2/example/test/Thing/AnotherThing/NestedTest.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,4 +0,0 @@ -module Thing.AnotherThing.NestedTest where - -prop_twoIsTwo :: Bool -prop_twoIsTwo = 2 == (2 :: Integer) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/executable/Main.hs new/tasty-discover-3.0.2/executable/Main.hs --- old/tasty-discover-1.1.0/executable/Main.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/tasty-discover-3.0.2/executable/Main.hs 2017-06-04 01:56:06.000000000 +0200 @@ -0,0 +1,32 @@ +-- | Main executable module. +module Main where + +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 () +main = do + args <- getArgs + name <- getProgName + case args of + src : _ : dst : opts -> + case parseConfig name opts of + Left err -> do + hPutStrLn stderr err + exitFailure + Right config -> do + tests <- findTests src config + let ingredients = tastyIngredients config + moduleName = fromMaybe "Main" (generatedModuleName config) + output = generateTestDriver config moduleName ingredients src tests + when (debug config) $ hPutStrLn stderr output + writeFile dst output + _ -> do + hPutStrLn stderr "Usage: tasty-discover src _ dst [OPTION...]" + exitFailure diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/integration-test/test-configurable-module/FooMySuffix.hs new/tasty-discover-3.0.2/integration-test/test-configurable-module/FooMySuffix.hs --- old/tasty-discover-1.1.0/integration-test/test-configurable-module/FooMySuffix.hs 2016-09-27 00:48:35.000000000 +0200 +++ new/tasty-discover-3.0.2/integration-test/test-configurable-module/FooMySuffix.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,4 +0,0 @@ -module FooMySuffix where - -prop_theNumberOfTheBeast :: Bool -prop_theNumberOfTheBeast = 666 == (666 :: Integer) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/integration-test/test-configurable-module/Nested/BarMySuffix.hs new/tasty-discover-3.0.2/integration-test/test-configurable-module/Nested/BarMySuffix.hs --- old/tasty-discover-1.1.0/integration-test/test-configurable-module/Nested/BarMySuffix.hs 2016-09-27 00:48:35.000000000 +0200 +++ new/tasty-discover-3.0.2/integration-test/test-configurable-module/Nested/BarMySuffix.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,4 +0,0 @@ -module Nested.BarMySuffix where - -prop_theMeaningOfLife :: Bool -prop_theMeaningOfLife = 42 == (42 :: Integer) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/integration-test/test-configurable-module/Tasty.hs new/tasty-discover-3.0.2/integration-test/test-configurable-module/Tasty.hs --- old/tasty-discover-1.1.0/integration-test/test-configurable-module/Tasty.hs 2016-09-27 00:48:35.000000000 +0200 +++ new/tasty-discover-3.0.2/integration-test/test-configurable-module/Tasty.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -{-# OPTIONS_GHC -F -pgmF tasty-discover -optF --module-suffix=MySuffix #-} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/integration-test/test-no-module-suffix/Nested/AnotherBar.hs new/tasty-discover-3.0.2/integration-test/test-no-module-suffix/Nested/AnotherBar.hs --- old/tasty-discover-1.1.0/integration-test/test-no-module-suffix/Nested/AnotherBar.hs 2016-10-24 01:38:37.000000000 +0200 +++ new/tasty-discover-3.0.2/integration-test/test-no-module-suffix/Nested/AnotherBar.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,4 +0,0 @@ -module Nested.AnotherBar where - -prop_someOtherTest :: Bool -prop_someOtherTest = 12 == (12 :: Integer) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/integration-test/test-no-module-suffix/SomeFoo.hs new/tasty-discover-3.0.2/integration-test/test-no-module-suffix/SomeFoo.hs --- old/tasty-discover-1.1.0/integration-test/test-no-module-suffix/SomeFoo.hs 2016-10-24 01:38:37.000000000 +0200 +++ new/tasty-discover-3.0.2/integration-test/test-no-module-suffix/SomeFoo.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,6 +0,0 @@ -module SomeFoo where - -import Data.Maybe (isNothing) - -prop_whatIsHapeningHere :: Bool -prop_whatIsHapeningHere = isNothing Nothing diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/integration-test/test-no-module-suffix/Tasty.hs new/tasty-discover-3.0.2/integration-test/test-no-module-suffix/Tasty.hs --- old/tasty-discover-1.1.0/integration-test/test-no-module-suffix/Tasty.hs 2016-10-24 01:38:37.000000000 +0200 +++ new/tasty-discover-3.0.2/integration-test/test-no-module-suffix/Tasty.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -{-# OPTIONS_GHC -F -pgmF tasty-discover -optF --no-module-suffix #-} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/library/Test/Tasty/Config.hs new/tasty-discover-3.0.2/library/Test/Tasty/Config.hs --- old/tasty-discover-1.1.0/library/Test/Tasty/Config.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/tasty-discover-3.0.2/library/Test/Tasty/Config.hs 2017-06-04 01:56:06.000000000 +0200 @@ -0,0 +1,68 @@ +-- Configuration options module. +module Test.Tasty.Config + ( Config(..) + , parseConfig + , defaultConfig + ) where + +import Data.Maybe (isJust) +import System.Console.GetOpt (ArgDescr (NoArg, ReqArg), + ArgOrder (Permute), OptDescr (Option), + getOpt) + +type Ingredient = String + +data Config = Config + { moduleSuffix :: Maybe String + , generatedModuleName :: Maybe String + , ignoredModules :: [FilePath] + , tastyIngredients :: [Ingredient] + , noModuleSuffix :: Bool + , debug :: Bool + , treeDisplay :: Bool + } deriving (Show) + +-- | The default configuration +defaultConfig :: Config +defaultConfig = Config Nothing Nothing [] [] False False False + +-- | Configuration options parser. +parseConfig :: String -> [String] -> Either String Config +parseConfig prog args = case getOpt Permute options args of + (opts, [], []) -> + let config = foldl (flip id) defaultConfig opts + errorMsg = "You cannot combine '--no-module-suffix' and '--module-suffix'\n" + in + if noModuleSuffix config && isJust (moduleSuffix config) + then formatError errorMsg + else Right config + (_, _, err:_) -> formatError err + (_, arg:_, _) -> formatError ("unexpected argument `" ++ arg ++ "`\n") + where + formatError err = Left (prog ++ ": " ++ err) + +-- | All configuration options. +options :: [OptDescr (Config -> Config)] +options = [ + Option [] ["module-suffix"] + (ReqArg (\s c -> c {moduleSuffix = Just s}) "SUFFIX") + "Specify desired test module suffix" + , Option [] ["generated-module"] + (ReqArg (\s c -> c {generatedModuleName = Just s}) "MODULE") + "Qualified generated module name" + , Option [] ["ignore-module"] + (ReqArg (\s c -> c {ignoredModules = s : ignoredModules c}) "FILE") + "Ignore a test module" + , Option [] ["ingredient"] + (ReqArg (\s c -> c {tastyIngredients = s : tastyIngredients c}) "INGREDIENT") + "Qualified tasty ingredient name" + , Option [] ["no-module-suffix"] + (NoArg $ \c -> c {noModuleSuffix = True}) + "Ignore test module suffix and import them all" + , Option [] ["debug"] + (NoArg $ \c -> c {debug = True}) + "Debug output of generated test module" + , Option [] ["tree-display"] + (NoArg $ \c -> c {treeDisplay = True}) + "Display test output hierarchically" + ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/library/Test/Tasty/Discover.hs new/tasty-discover-3.0.2/library/Test/Tasty/Discover.hs --- old/tasty-discover-1.1.0/library/Test/Tasty/Discover.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/tasty-discover-3.0.2/library/Test/Tasty/Discover.hs 2017-06-04 01:56:06.000000000 +0200 @@ -0,0 +1,131 @@ +-- | Automatic test discovery and runner for the tasty framework. +module Test.Tasty.Discover where + +import Data.List (dropWhileEnd, intercalate, isPrefixOf, + isSuffixOf, nub) +import qualified Data.Map.Strict as M +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 :: Config -> String -> [String] -> FilePath -> [Test] -> String +generateTestDriver config modname is src tests = + let generators' = getGenerators tests + testNumVars = map (("t"++) . show) [(0 :: Int)..] + in + concat + [ "{-# LINE 1 \"" ++ src ++ "\" #-}\n" + , "{-# LANGUAGE FlexibleInstances #-}\n" + , "module " ++ modname ++ " (main, ingredients, tests) where\n" + , "import Prelude\n" + , "import qualified Test.Tasty as T\n" + , "import qualified Test.Tasty.Ingredients as T\n" + , unlines $ map generatorImport generators' + , showImports (map ingredientImport is ++ map testModule tests) + , unlines $ map generatorClass generators' + , "tests :: IO T.TestTree\n" + , "tests = do\n" + , unlines $ zipWith showSetup tests testNumVars + , " pure $ T.testGroup \"" ++ src ++ "\" [" + , intercalate "," $ showTests config tests testNumVars + , "]\n" + , concat + [ "ingredients :: [T.Ingredient]\n" + , "ingredients = " ++ ingredients is ++ "\n" + , "main :: IO ()\n" + , "main = tests >>= T.defaultMainWithIngredients ingredients\n" + ] + ] + +addSuffixes :: [String] -> [String] +addSuffixes modules = (++) <$> modules <*> [".lhs", ".hs"] + +isHidden :: FilePath -> Bool +isHidden filename = head filename /= '.' + +filesBySuffix :: FilePath -> [String] -> IO [FilePath] +filesBySuffix dir suffixes = do + entries <- filter isHidden <$> getDirectoryContents dir + fmap concat $ for entries $ \entry -> do + let dir' = dir </> entry + dirExists <- doesDirectoryExist dir' + if dirExists then + map (entry </>) <$> filesBySuffix dir' suffixes + else if any (`isSuffixOf` entry) suffixes then + pure [entry] + else + pure [] + +isIgnored :: [FilePath] -> String -> Bool +isIgnored ignores filename = filename `notElem` addSuffixes ignores + +findTests :: FilePath -> Config -> IO [Test] +findTests src config = do + let dir = takeDirectory src + suffixes = testFileSuffixes config + ignores = ignoredModules config + files <- filter (isIgnored ignores) <$> filesBySuffix dir suffixes + concat <$> traverse (extract dir) files + where + extract dir file = extractTests file <$> readFile (dir </> file) + +extractTests :: FilePath -> String -> [Test] +extractTests file = mkTestDeDuped . isKnownPrefix . parseTest + where + mkTestDeDuped = map (mkTest file) . nub + isKnownPrefix = filter (\g -> any (checkPrefix g) generators) + checkPrefix g = (`isPrefixOf` g) . generatorPrefix + parseTest = map fst . concatMap lex . lines + +testFileSuffixes :: Config -> [String] +testFileSuffixes config = if noModuleSuffix config + then [""] + else addSuffixes suffixes + where + suffixes = case moduleSuffix config of + Just suffix' -> [suffix'] + Nothing -> ["Spec", "Test"] + +showImports :: [String] -> String +showImports mods = unlines $ nub $ map (\m -> "import qualified " ++ m ++ "\n") mods + +ingredientImport :: String -> String +ingredientImport = init . dropWhileEnd (/= '.') + +ingredients :: [String] -> String +ingredients is = concat $ map (++":") is ++ ["T.defaultIngredients"] + +showTests :: Config -> [Test] -> [String] -> [String] +showTests config tests testNumVars = if treeDisplay config + then showModuleTree $ mkModuleTree tests testNumVars + else zipWith (curry snd) tests testNumVars + +newtype ModuleTree = ModuleTree (M.Map String (ModuleTree, [String])) + deriving (Eq, Show) + +showModuleTree :: ModuleTree -> [String] +showModuleTree (ModuleTree mdls) = map showModule $ M.assocs mdls + where + -- special case, collapse to mdl.submdl + showModule (mdl, (ModuleTree subMdls, [])) | M.size subMdls == 1 = + let [(subMdl, (subSubTree, testVars))] = M.assocs subMdls + in showModule (mdl ++ '.' : subMdl, (subSubTree, testVars)) + showModule (mdl, (subTree, testVars)) = concat + [ "T.testGroup \"", mdl + , "\" [", intercalate "," (showModuleTree subTree ++ testVars), "]" ] + +mkModuleTree :: [Test] -> [String] -> ModuleTree +mkModuleTree tests testVars = ModuleTree $ + foldr go M.empty $ zipWith (\t tVar -> (testModule t, tVar)) tests testVars + where + go (mdl, tVar) mdls = M.insertWith merge key val mdls + where + (key, val) = case break (== '.') mdl of + (_, []) -> (mdl, (ModuleTree M.empty, [tVar])) + (topMdl, '.':subMdl) -> (topMdl, (ModuleTree $ go (subMdl, tVar) M.empty, [])) + _ -> error "impossible case in mkModuleTree.go.key" + merge (ModuleTree mdls1, tVars1) (ModuleTree mdls2, tVars2) = + (ModuleTree $ M.unionWith merge mdls1 mdls2, tVars1 ++ tVars2) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/library/Test/Tasty/Generator.hs new/tasty-discover-3.0.2/library/Test/Tasty/Generator.hs --- old/tasty-discover-1.1.0/library/Test/Tasty/Generator.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/tasty-discover-3.0.2/library/Test/Tasty/Generator.hs 2017-06-04 01:56:06.000000000 +0200 @@ -0,0 +1,124 @@ +module Test.Tasty.Generator + ( Generator(..) + , generators + , showSetup + , getGenerator + , getGenerators + , Test(..) + , mkTest, + ) where + +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 + , 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 + +name :: Test -> String +name = chooser '_' ' ' . tail . dropWhile (/= '_') . testFunction + where chooser c1 c2 = map $ \c3 -> if c3 == c1 then c2 else c3 + +getGenerator :: Test -> Generator +getGenerator t = fromJust $ getPrefix generators + where getPrefix = find ((`isPrefixOf` testFunction t) . generatorPrefix) + +getGenerators :: [Test] -> [Generator] +getGenerators = + map head . + groupBy ((==) `on` generatorPrefix) . + sortOn generatorPrefix . + map getGenerator + +showSetup :: Test -> String -> String +showSetup t var = " " ++ var ++ " <- " ++ setup ++ "\n" + where setup = generatorSetup (getGenerator t) t + +generators :: [Generator] +generators = + [ quickCheckPropertyGenerator + , hunitTestCaseGeneratorDeprecated + , hunitTestCaseGenerator + , hspecTestCaseGenerator + , tastyTestGroupGenerator + ] + +quickCheckPropertyGenerator :: Generator +quickCheckPropertyGenerator = Generator + { generatorPrefix = "prop_" + , generatorImport = "import qualified Test.Tasty.QuickCheck as QC\n" + , generatorClass = "" + , generatorSetup = \t -> "pure $ QC.testProperty \"" ++ name t ++ "\" " ++ qualifyFunction t + } + +deprecationMessage :: String +deprecationMessage = + error $ concat + [ "\n\n" + , "----------------------------------------------------------\n" + , "DEPRECATION NOTICE: The `case_` prefix is deprecated.\n" + , "Please use the `unit_` prefix instead.\n" + , "Please see https://github.com/lwm/tasty-discover/issues/95.\n" + , "----------------------------------------------------------\n" + ] + +-- DEPRECATED: Use `unit_` instead (below) +hunitTestCaseGeneratorDeprecated :: Generator +hunitTestCaseGeneratorDeprecated = Generator + { generatorPrefix = "case_" + , generatorImport = deprecationMessage + , generatorClass = deprecationMessage + , generatorSetup = const deprecationMessage + } + +hunitTestCaseGenerator :: Generator +hunitTestCaseGenerator = Generator + { generatorPrefix = "unit_" + , generatorImport = "import qualified Test.Tasty.HUnit as HU\n" + , generatorClass = concat + [ "class TestCase a where testCase :: String -> a -> IO T.TestTree\n" + , "instance TestCase (IO ()) where testCase n = pure . HU.testCase n\n" + , "instance TestCase (IO String) where testCase n = pure . HU.testCaseInfo n\n" + , "instance TestCase ((String -> IO ()) -> IO ()) where testCase n = pure . HU.testCaseSteps n\n" + ] + , generatorSetup = \t -> "testCase \"" ++ name t ++ "\" " ++ qualifyFunction t + } + +hspecTestCaseGenerator :: Generator +hspecTestCaseGenerator = Generator + { generatorPrefix = "spec_" + , generatorImport = "import qualified Test.Tasty.Hspec as HS\n" + , generatorClass = "" + , generatorSetup = \t -> "HS.testSpec \"" ++ name t ++ "\" " ++ qualifyFunction t + } + +tastyTestGroupGenerator :: Generator +tastyTestGroupGenerator = Generator + { generatorPrefix = "test_" + , generatorImport = "" + , generatorClass = concat + [ "class TestGroup a where testGroup :: String -> a -> IO T.TestTree\n" + , "instance TestGroup T.TestTree where testGroup _ a = pure a\n" + , "instance TestGroup [T.TestTree] where testGroup n a = pure $ T.testGroup n a\n" + , "instance TestGroup (IO T.TestTree) where testGroup _ a = a\n" + , "instance TestGroup (IO [T.TestTree]) where testGroup n a = T.testGroup n <$> a\n" + ] + , generatorSetup = \t -> "testGroup \"" ++ name t ++ "\" " ++ qualifyFunction t + } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/src/Main.hs new/tasty-discover-3.0.2/src/Main.hs --- old/tasty-discover-1.1.0/src/Main.hs 2016-11-12 13:24:28.000000000 +0100 +++ new/tasty-discover-3.0.2/src/Main.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,11 +0,0 @@ --- | Main module and entry point. - -module Main where - -import System.Environment (getArgs) - -import Test.Tasty.Run (run) - --- | Pass pre processor arguments. -main :: IO () -main = getArgs >>= run diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/src/Test/Tasty/Config.hs new/tasty-discover-3.0.2/src/Test/Tasty/Config.hs --- old/tasty-discover-1.1.0/src/Test/Tasty/Config.hs 2017-01-19 21:44:52.000000000 +0100 +++ new/tasty-discover-3.0.2/src/Test/Tasty/Config.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,26 +0,0 @@ --- | Preprocessor configuration. - -module Test.Tasty.Config ( - Config(..) -, defaultConfig -, options -) where - -import System.Console.GetOpt (ArgDescr (ReqArg, NoArg) , OptDescr (Option)) - -import Test.Tasty.Type (Config(..)) - --- | The empty configuration. -defaultConfig :: Config -defaultConfig = Config Nothing False [] - --- | All configuration options. -options :: [OptDescr (Config -> Config)] -options = [ - Option [] ["module-suffix"] - (ReqArg (\s c -> c {configModuleSuffix = Just s}) "SUFFIX") "" - , Option [] ["no-module-suffix"] - (NoArg $ \c -> c {noModuleSuffix = True}) "" - , Option [] ["ignore-module"] - (ReqArg (\s c -> c {ignoredModules = s : ignoredModules c}) "FILE") "" - ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/src/Test/Tasty/Discover.hs new/tasty-discover-3.0.2/src/Test/Tasty/Discover.hs --- old/tasty-discover-1.1.0/src/Test/Tasty/Discover.hs 2016-11-12 13:24:29.000000000 +0100 +++ new/tasty-discover-3.0.2/src/Test/Tasty/Discover.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,17 +0,0 @@ --- | Automatic test discovery and runner for the tasty framework. - -module Test.Tasty.Discover (module Discover) where - --- 3rd party -import Test.Tasty as Discover -import Test.Tasty.HUnit as Discover -import Test.Tasty.QuickCheck as Discover -import Test.Tasty.TH as Discover -import Test.Tasty.Hspec as Discover - --- `tasty-discover` modules -import Test.Tasty.Run as Discover -import Test.Tasty.Parse as Discover -import Test.Tasty.Type as Discover -import Test.Tasty.Config as Discover -import Test.Tasty.Util as Discover diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/src/Test/Tasty/Parse.hs new/tasty-discover-3.0.2/src/Test/Tasty/Parse.hs --- old/tasty-discover-1.1.0/src/Test/Tasty/Parse.hs 2016-11-12 13:24:29.000000000 +0100 +++ new/tasty-discover-3.0.2/src/Test/Tasty/Parse.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,25 +0,0 @@ --- | Parser for the GHC preprocessor definition. - -module Test.Tasty.Parse ( - parseConfig -) where - -import Data.Maybe (isJust) -import System.Console.GetOpt (ArgOrder (Permute), getOpt) - -import Test.Tasty.Config (Config(..), defaultConfig, options) - --- | Preprocessor configuration parser. -parseConfig :: String -> [String] -> Either String Config -parseConfig prog args = case getOpt Permute options args of - (opts, [], []) -> - let config = foldl (flip id) defaultConfig opts - errorMsg = "You cannot combine '--no-module-suffix' and '--module-suffix'\n" - in - if noModuleSuffix config && isJust (configModuleSuffix config) - then formatError errorMsg - else Right config - (_, _, err:_) -> formatError err - (_, arg:_, _) -> formatError ("unexpected argument `" ++ arg ++ "`\n") - where - formatError err = Left (prog ++ ": " ++ err) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/src/Test/Tasty/Run.hs new/tasty-discover-3.0.2/src/Test/Tasty/Run.hs --- old/tasty-discover-1.1.0/src/Test/Tasty/Run.hs 2016-11-12 13:24:30.000000000 +0100 +++ new/tasty-discover-3.0.2/src/Test/Tasty/Run.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,54 +0,0 @@ --- | Test discovery and runner boilerplate generator. - -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE TypeSynonymInstances #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} - -module Test.Tasty.Run ( - run -, tmpModule -) where - -import System.Environment (getProgName) -import System.IO (hPutStrLn, stderr) -import System.Exit (exitFailure) - -import Test.Tasty.Parse (parseConfig) -import Test.Tasty.Util (importList, findTests, getListOfTests) -import Test.Tasty.Type (Config, Test) - --- | Parse preprocessor arguments and write the test runner module. -run :: [String] -> IO () -run processor_args = do - name <- getProgName - case processor_args of - src : _ : dst : opts -> case parseConfig name opts of - - Left err -> do - hPutStrLn stderr err - exitFailure - - Right conf -> do - stringed <- show <$> getListOfTests src conf - tests <- findTests src conf - writeFile dst (tmpModule src conf tests stringed) - - _ -> do - hPutStrLn stderr name - exitFailure - - --- | Generate the test runner module. -tmpModule :: FilePath -> Config -> [Test] -> String -> String -tmpModule src conf tests ts = - ( - "{-# LINE 1 " . shows src . " #-}\n" - . showString "{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}\n" - . showString "{-# LANGUAGE TemplateHaskell #-}\n" - . showString "module Main where\n" - . showString "import Test.Tasty.Discover\n" - . importList tests conf - . showString "main :: IO ()\n" - . showString ("main = do $(defaultMainGeneratorFor \"tasty-discover\" " ++ ts ++ ")") - ) "\n" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/src/Test/Tasty/Type.hs new/tasty-discover-3.0.2/src/Test/Tasty/Type.hs --- old/tasty-discover-1.1.0/src/Test/Tasty/Type.hs 2017-01-19 21:44:52.000000000 +0100 +++ new/tasty-discover-3.0.2/src/Test/Tasty/Type.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,18 +0,0 @@ --- | Types. - -module Test.Tasty.Type where - --- | A test type. Corresponds to a test file path and module name. -data Test = Test { - testFile :: FilePath -, testModule :: String -} deriving (Eq, Show) - --- | A configuration type. --- Constructor values are parsed from the preprocessor file. -data Config = Config { - configModuleSuffix :: Maybe String -, noModuleSuffix :: Bool -, ignoredModules :: [FilePath] -} deriving (Eq, Show) - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/src/Test/Tasty/Util.hs new/tasty-discover-3.0.2/src/Test/Tasty/Util.hs --- old/tasty-discover-1.1.0/src/Test/Tasty/Util.hs 2017-01-19 21:44:52.000000000 +0100 +++ new/tasty-discover-3.0.2/src/Test/Tasty/Util.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,135 +0,0 @@ --- | Utility functions. - -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE OverloadedStrings #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} - -module Test.Tasty.Util ( - importList -, findTests -, getListOfTests - --- Testing purposes -, fileToTest -, getFilesRecursive -, isValidModuleChar -, isValidModuleName -) where - -import Control.Applicative ((<|>)) -import Control.Monad (filterM) -import Data.Char (isAlphaNum, isUpper) -import Data.List (intercalate, sort, stripPrefix) -import Data.Maybe (mapMaybe) -import Data.String (IsString, fromString) -import System.Directory (doesDirectoryExist, doesFileExist, getDirectoryContents) -import System.FilePath (splitDirectories, splitFileName, (</>)) -import System.FilePath.Posix (splitExtension) - -import Test.Tasty.TH (extractTestFunctions) - -import Test.Tasty.Config (Config(..)) -import Test.Tasty.Type - -instance IsString ShowS where - fromString = showString - --- | Import statements for a list of tests. -importList :: [Test] -> Config -> ShowS -importList ts config = - foldr ((.) . f) "" ts - where - f :: Test -> ShowS - f test = if noModuleSuffix config then - "import " . showString (testModule test) . "\n" - else - case configModuleSuffix config of - Just suffix' -> "import " . showString (testModule test) . showString (suffix' ++ "\n") - _ -> "import " . showString (testModule test) . "Test\n" - - --- | Is 'c' a valid character in a Haskell module name? -isValidModuleChar :: Char -> Bool -isValidModuleChar c = isAlphaNum c || c == '_' || c == '\'' - --- | Is 'cs' a valid Haskell module name? -isValidModuleName :: String -> Bool -isValidModuleName [] = False -isValidModuleName (c:cs) = isUpper c && all isValidModuleChar cs - --- | All files under 'baseDir'. -getFilesRecursive :: FilePath -> IO [FilePath] -getFilesRecursive baseDir = sort <$> go [] - where - go :: FilePath -> IO [FilePath] - go dir = do - c <- map (dir </>) . filter (`notElem` [".", ".."]) <$> getDirectoryContents (baseDir </> dir) - dirs <- filterM (doesDirectoryExist . (baseDir </>)) c >>= mapM go - files <- filterM (doesFileExist . (baseDir </>)) c - return (files ++ concat dirs) - --- | Convert a file to a File type. -fileToTest :: FilePath -> Config -> FilePath -> Maybe Test -fileToTest dir conf file = - let - suffix :: Maybe String - suffix = configModuleSuffix conf - - noModule :: Bool - noModule = noModuleSuffix conf - - files :: [FilePath] - files = reverse $ splitDirectories file - in - if noModule then catchAll files else case suffix of - Just suffix' -> filterBySuffix suffix' files - Nothing -> filterBySuffix "Test" files - where - filterBySuffix :: String -> [FilePath] -> Maybe Test - filterBySuffix suffix files = - case files of - x:xs -> case - stripSuffix (suffix ++ ".hs") x <|> stripSuffix (suffix ++ ".lhs") x of - Just name | isValidModuleName name && all isValidModuleName xs -> - let pathComponents = reverse (name : xs) - moduleName = intercalate "." pathComponents - in if isIgnoredModule pathComponents - then Nothing - else Just . Test (dir </> file) $ moduleName - _ -> Nothing - _ -> Nothing - - isIgnoredModule :: [FilePath] -> Bool - isIgnoredModule pathComponents = - let moduleName = intercalate "." pathComponents - in moduleName `elem` ignoredModules conf - - stripSuffix :: Eq a => [a] -> [a] -> Maybe [a] - stripSuffix suff str = reverse <$> stripPrefix (reverse suff) (reverse str) - - catchAll :: [FilePath] -> Maybe Test - catchAll (x:xs) = - let name = fst $ splitExtension x - pathComponents = reverse (name : xs) - in - if isValidModuleName name - && all isValidModuleName xs - && not (isIgnoredModule pathComponents) then - Just . Test (dir </> file) $ (intercalate "." . reverse) (name : xs) - else Nothing - catchAll _ = Nothing - --- | All test modules under 'dir'. -findTests :: FilePath -> Config -> IO [Test] -findTests path config = - let (dir, file) = splitFileName path - tests = mapMaybe $ fileToTest dir config - in - tests . filter (/= file) <$> getFilesRecursive dir - --- | All test function names in 'src'. -getListOfTests :: FilePath -> Config -> IO [String] -getListOfTests src conf = do - allFiles <- fmap testFile <$> findTests src conf - allTests <- mapM extractTestFunctions allFiles - return $ concat allTests diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/tasty-discover.cabal new/tasty-discover-3.0.2/tasty-discover.cabal --- old/tasty-discover-1.1.0/tasty-discover.cabal 2017-01-19 21:45:16.000000000 +0100 +++ new/tasty-discover-3.0.2/tasty-discover.cabal 2017-06-04 10:19:58.000000000 +0200 @@ -1,87 +1,79 @@ -name: tasty-discover -version: 1.1.0 -license: GPL-3 -license-file: LICENSE.md -copyright: (c) 2016 Luke Murphy -author: Luke Murphy <lukewm@riseup.net> -maintainer: Luke Murphy <lukewm@riseup.net> -build-type: Simple -cabal-version: >= 1.22 -category: Testing -stability: Stable -bug-reports: https://github.com/lwm/tasty-discover/issues -homepage: https://github.com/lwm/tasty-discover/ -synopsis: Test discovery for the tasty framework. -description: Test discovery for the tasty framework. +-- This file has been generated from package.yaml by hpack version 0.17.0. +-- +-- see: https://github.com/sol/hpack + +name: tasty-discover +version: 3.0.2 +synopsis: Test discovery for the tasty framework. +description: Automatic test discovery and runner for the tasty framework. + 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 +maintainer: Luke Murphy <lukewm@riseup.net> +copyright: 2016 Luke Murphy +license: MIT +license-file: LICENSE +build-type: Simple +cabal-version: >= 1.10 + extra-source-files: - integration-test/test-configurable-module/*.hs - integration-test/test-configurable-module/Nested/*.hs - integration-test/test-no-module-suffix/*.hs - integration-test/test-no-module-suffix/Nested/*.hs - example/test/*.hs - example/test/AllTheFolders/*.hs - example/test/Thing/AnotherThing/*.hs - test/tmpdir/*.hs - test/tmpdir/*.md + CHANGELOG.md + README.md + +source-repository head + type: git + location: https://github.com/lwm/tasty-discover library - ghc-options: - -Wall - exposed-modules: - Test.Tasty.Discover - other-modules: - Test.Tasty.Config - Test.Tasty.Parse - Test.Tasty.Run - Test.Tasty.Util - Test.Tasty.Type + hs-source-dirs: + library + ghc-options: -Wall build-depends: - base == 4.* - , filepath - , directory - , tasty - , tasty-th - , tasty-hunit - , tasty-quickcheck - , tasty-hspec - hs-source-dirs: src + base >= 4.8 && < 5.0 + , containers >= 0.4 && < 1.0 + , directory >= 1.1 && < 2.0 + , filepath >= 1.3 && < 2.0 + exposed-modules: + Test.Tasty.Config + Test.Tasty.Discover + Test.Tasty.Generator default-language: Haskell2010 executable tasty-discover - ghc-options: - -Wall - hs-source-dirs: - src - main-is: - Main.hs - other-modules: - Test.Tasty.Config - Test.Tasty.Discover - Test.Tasty.Parse - Test.Tasty.Run - Test.Tasty.Util - Test.Tasty.Type + main-is: executable/Main.hs + ghc-options: -Wall build-depends: - base == 4.* - , filepath - , directory + base >= 4.8 && < 5.0 + , containers >= 0.4 && < 1.0 + , directory >= 1.1 && < 2.0 + , filepath >= 1.3 && < 2.0 , tasty-discover - , tasty-th default-language: Haskell2010 -test-suite unit-tests - type: exitcode-stdio-1.0 - hs-source-dirs: test - main-is: Tasty.hs - other-modules: - ParseTest - RunnerTest - UtilTest +test-suite test + type: exitcode-stdio-1.0 + main-is: Tasty.hs + hs-source-dirs: + test + ghc-options: -Wall build-depends: - base == 4.* + base >= 4.8 && < 5.0 + , containers >= 0.4 && < 1.0 + , directory >= 1.1 && < 2.0 + , filepath >= 1.3 && < 2.0 + , base + , tasty , tasty-discover - default-language: Haskell2010 - -Source-repository head - type: git - location: git://github.com/lwm/tasty-discover.git + , tasty-hspec + , tasty-hunit + , tasty-quickcheck + , tasty-smallcheck + other-modules: + ConfigTest + DiscoverTest + SubMod.FooBaz + SubMod.PropTest + default-language: Haskell2010 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/test/ConfigTest.hs new/tasty-discover-3.0.2/test/ConfigTest.hs --- old/tasty-discover-1.1.0/test/ConfigTest.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/tasty-discover-3.0.2/test/ConfigTest.hs 2017-06-04 01:56:06.000000000 +0200 @@ -0,0 +1,80 @@ +{-# OPTIONS_GHC -fno-warn-orphans #-} +module ConfigTest where + +import Data.List (isInfixOf) +import qualified Data.Map.Strict as M +import Test.Tasty.Config +import Test.Tasty.Discover (ModuleTree (..), findTests, + generateTestDriver, mkModuleTree, + showTests) +import Test.Tasty.Generator (Test (..), mkTest) +import Test.Tasty.HUnit +import Test.Tasty.QuickCheck + +unit_noModuleSuffixEmptyList :: IO () +unit_noModuleSuffixEmptyList = do + actual <- findTests "test/SubMod/" (defaultConfig { moduleSuffix = Just "DoesntExist"}) + actual @?= [] + +unit_differentGeneratedModule :: Assertion +unit_differentGeneratedModule = assertBool "" ("FunkyModuleName" `isInfixOf` generatedModule) + where generatedModule = generateTestDriver defaultConfig "FunkyModuleName" [] "test/" [] + +unit_ignoreAModule :: IO () +unit_ignoreAModule = do + actual <- findTests "test/SubMod/" (defaultConfig { ignoredModules = ["PropTest"] }) + actual @?= [] + +unit_noModuleSuffix :: IO () +unit_noModuleSuffix = do + actual1 <- findTests "test/SubMod/" defaultConfig + actual1 @?= [mkTest "PropTest" "prop_additionAssociative"] + + actual2 <- findTests "test/SubMod/" (defaultConfig { noModuleSuffix = True }) + let expected = [ mkTest "FooBaz" "prop_additionCommutative" + , mkTest "FooBaz" "prop_multiplationDistributiveOverAddition" + , mkTest "PropTest" "prop_additionAssociative" ] + assertBool "" $ all (`elem` expected) actual2 + +unit_noModuleSuffixRecurseDirs :: IO () +unit_noModuleSuffixRecurseDirs = do + tests <- findTests "test/" (defaultConfig { noModuleSuffix = True }) + assertBool "" $ elem (mkTest "SubMod/FooBaz" "prop_additionCommutative") tests + +unit_noTreeDisplayDefault :: IO () +unit_noTreeDisplayDefault = do + let config = defaultConfig { noModuleSuffix = True } + tests <- findTests "test/SubMod/" config + let testNumVars = map (('t' :) . show) [(0::Int)..] + trees = showTests config tests testNumVars + length trees @?= 3 + +unit_treeDisplay :: IO () +unit_treeDisplay = do + let config = defaultConfig { noModuleSuffix = True, treeDisplay = True } + tests <- findTests "test/SubMod/" config + let testNumVars = map (('t' :) . show) [(0::Int)..] + trees = showTests config tests testNumVars + length trees @?= 2 + +prop_mkModuleTree :: ModuleTree -> Property +prop_mkModuleTree mtree = + let (tests, testVars) = unzip $ flattenTree mtree + in mkModuleTree tests testVars === mtree + where + flattenTree (ModuleTree mp) = M.assocs mp >>= flattenModule + flattenModule (mdl, (subTree, testVars)) = concat + [ map (\(Test subMdl _, tVar) -> (Test (mdl ++ '.':subMdl) "-", tVar)) (flattenTree subTree) + , map (\tVar -> (Test mdl "-", tVar)) testVars ] + +instance Arbitrary ModuleTree where + arbitrary = sized $ \size -> + resize (min size 12) (ModuleTree . M.fromList <$> listOf1 mdlGen) + where + mdlGen = sized $ \size -> do + mdl <- listOf1 (elements ['a'..'z']) + subTree <- if size == 0 + then pure $ ModuleTree M.empty + else resize (size `div` 2) arbitrary + tVars <- listOf1 (listOf1 arbitrary) + pure (mdl, (subTree, tVars)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/test/DiscoverTest.hs new/tasty-discover-3.0.2/test/DiscoverTest.hs --- old/tasty-discover-1.1.0/test/DiscoverTest.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/tasty-discover-3.0.2/test/DiscoverTest.hs 2017-06-04 00:46:53.000000000 +0200 @@ -0,0 +1,43 @@ +{-# LANGUAGE ScopedTypeVariables #-} + +module DiscoverTest where + +import Data.List +import Test.Tasty +import Test.Tasty.Hspec +import Test.Tasty.HUnit +import Test.Tasty.QuickCheck + +unit_listCompare :: IO () +unit_listCompare = [1 :: Int, 2, 3] `compare` [1,2] @?= GT + +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) + +spec_prelude :: Spec +spec_prelude = + describe "Prelude.head" $ + it "returns the first element of a list" $ + head [23 ..] `shouldBe` (23 :: Int) + +test_addition :: TestTree +test_addition = testProperty "Addition commutes" $ \(a :: Int) (b :: Int) -> a + b == b + a + +test_multiplication :: [TestTree] +test_multiplication = + [ testProperty "Multiplication commutes" $ \(a :: Int) (b :: Int) -> a * b == b * a + , testProperty "One is identity" $ \(a :: Int) -> a == a + ] + +test_generateTree :: IO TestTree +test_generateTree = do + input <- pure "Some input" + pure $ testCase input $ pure () + +test_generateTrees :: IO [TestTree] +test_generateTrees = do + inputs <- pure ["First input", "Second input"] + pure $ map (\s -> testCase s $ pure ()) inputs diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/test/ParseTest.hs new/tasty-discover-3.0.2/test/ParseTest.hs --- old/tasty-discover-1.1.0/test/ParseTest.hs 2017-01-19 21:44:52.000000000 +0100 +++ new/tasty-discover-3.0.2/test/ParseTest.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,45 +0,0 @@ --- Unit tests for Test.Tasty.Parse module. - -module ParseTest where - -import Test.Tasty.Discover (parseConfig, Config(..), - Assertion, (@?=)) - -case_parseConfig :: Assertion -case_parseConfig = - parseConfig "foo" ["--module-suffix=MySuffix"] - @?= - Right Config { configModuleSuffix=Just "MySuffix" - , noModuleSuffix=False - , ignoredModules=[] - } - -case_parseConfigMissingArg :: Assertion -case_parseConfigMissingArg = - parseConfig "foo" ["--module-suffix"] - @?= - Left "foo: option `--module-suffix' requires an argument SUFFIX\n" - -case_parseConfigEmptyArg :: Assertion -case_parseConfigEmptyArg = - parseConfig "foo" [] - @?= - Right (Config Nothing False []) - -case_parseConfigInvalidArg :: Assertion -case_parseConfigInvalidArg = - parseConfig "foo" ["a"] - @?= - Left "foo: unexpected argument `a`\n" - -case_parseConfigBooleanArg :: Assertion -case_parseConfigBooleanArg = - parseConfig "foo" ["--no-module-suffix"] - @?= - Right Config {configModuleSuffix=Nothing, noModuleSuffix=True, ignoredModules= []} - -case_parseConfigInvalidArgCombination :: Assertion -case_parseConfigInvalidArgCombination = - parseConfig "foo" ["--module-suffix=MySuffix", "--no-module-suffix"] - @?= - Left "foo: You cannot combine '--no-module-suffix' and '--module-suffix'\n" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/test/RunnerTest.hs new/tasty-discover-3.0.2/test/RunnerTest.hs --- old/tasty-discover-1.1.0/test/RunnerTest.hs 2016-11-12 13:24:32.000000000 +0100 +++ new/tasty-discover-3.0.2/test/RunnerTest.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,20 +0,0 @@ --- Unit tests to assure `tasty-discover` is discovering tests. - -module RunnerTest where - -import Test.Tasty.Discover (Assertion, (@?), defaultConfig, getListOfTests) - -case_unitTestsDiscovered :: Assertion -case_unitTestsDiscovered = do - unitTests <- getListOfTests "test" defaultConfig - (return $ null unitTests :: IO Bool) @? "Couldn't find any unit tests." - -case_integrationTestsDiscovered :: Assertion -case_integrationTestsDiscovered = do - integrationTests <- getListOfTests "integration-test/" defaultConfig - (return $ null integrationTests :: IO Bool) @? "Couldn't find any integration tests." - -case_exampleTestsDiscovered :: Assertion -case_exampleTestsDiscovered = do - exampleTests <- getListOfTests "example/" defaultConfig - (return $ null exampleTests :: IO Bool) @? "Couldn't find any example tests." diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/test/SubMod/FooBaz.hs new/tasty-discover-3.0.2/test/SubMod/FooBaz.hs --- old/tasty-discover-1.1.0/test/SubMod/FooBaz.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/tasty-discover-3.0.2/test/SubMod/FooBaz.hs 2017-06-04 01:56:06.000000000 +0200 @@ -0,0 +1,7 @@ +module SubMod.FooBaz where + +prop_additionCommutative :: Int -> Int -> Bool +prop_additionCommutative a b = a + b == b + a + +prop_multiplationDistributiveOverAddition :: Integer -> Integer -> Integer -> Bool +prop_multiplationDistributiveOverAddition a b c = a * (b + c) == a * b + a * c diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/test/SubMod/PropTest.hs new/tasty-discover-3.0.2/test/SubMod/PropTest.hs --- old/tasty-discover-1.1.0/test/SubMod/PropTest.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/tasty-discover-3.0.2/test/SubMod/PropTest.hs 2017-06-04 00:46:54.000000000 +0200 @@ -0,0 +1,4 @@ +module SubMod.PropTest where + +prop_additionAssociative :: Int -> Int -> Int -> Bool +prop_additionAssociative a b c = (a + b) + c == a + (b + c) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/test/UtilTest.hs new/tasty-discover-3.0.2/test/UtilTest.hs --- old/tasty-discover-1.1.0/test/UtilTest.hs 2017-01-19 21:44:52.000000000 +0100 +++ new/tasty-discover-3.0.2/test/UtilTest.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,40 +0,0 @@ --- Unit tests for Test.Tasty.Util module. - -module UtilTest where - -import Test.Tasty.Discover (Assertion, (@?=), defaultConfig, getListOfTests, - findTests, fileToTest, getFilesRecursive, - isValidModuleChar, isValidModuleName, - Config(..), Test(..)) - -case_getListOfTests :: Assertion -case_getListOfTests = do - result <- getListOfTests "test/tmpdir/" defaultConfig - result @?= ["case_foo"] - -case_getListOfTestsWithSuffix :: Assertion -case_getListOfTestsWithSuffix = do - let config = Config (Just "DoesntExist") False [] - result <- getListOfTests "test/tmpdir/" config - result @?= [] - -case_findTests :: Assertion -case_findTests = do - result <- findTests "test/tmpdir/" defaultConfig - result @?= [Test {testFile="test/tmpdir/FooTest.hs", testModule="Foo"}] - -case_fileToTest :: Assertion -case_fileToTest = do - let result = fileToTest "test/tmpdir/" defaultConfig "FooTest.hs" - result @?= Just Test {testFile="test/tmpdir/FooTest.hs", testModule="Foo"} - -case_getFilesRecursive :: Assertion -case_getFilesRecursive = do - result <- getFilesRecursive "test/tmpdir/" - result @?= ["FooTest.hs", "README.md"] - -case_isValidModuleChar :: Assertion -case_isValidModuleChar = isValidModuleChar 'C' @?= True - -case_isValidModuleName :: Assertion -case_isValidModuleName = isValidModuleName "Jim" @?= True diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/test/tmpdir/FooTest.hs new/tasty-discover-3.0.2/test/tmpdir/FooTest.hs --- old/tasty-discover-1.1.0/test/tmpdir/FooTest.hs 2016-11-12 13:24:31.000000000 +0100 +++ new/tasty-discover-3.0.2/test/tmpdir/FooTest.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,3 +0,0 @@ -module FooTest where - -case_foo = undefined diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tasty-discover-1.1.0/test/tmpdir/README.md new/tasty-discover-3.0.2/test/tmpdir/README.md --- old/tasty-discover-1.1.0/test/tmpdir/README.md 2016-10-24 13:13:27.000000000 +0200 +++ new/tasty-discover-3.0.2/test/tmpdir/README.md 1970-01-01 01:00:00.000000000 +0100 @@ -1,3 +0,0 @@ -# tmpdir - -This folder is used for various unit tests in the parent folder.
participants (1)
-
root@hilbert.suse.de