packages feed

test-framework-skip (empty) → 1.0

raw patch · 5 files changed

+144/−0 lines, 5 filesdep +HUnitdep +QuickCheckdep +basesetup-changed

Dependencies added: HUnit, QuickCheck, base, smallcheck, test-framework, test-framework-hunit, test-framework-quickcheck2, test-framework-skip, test-framework-smallcheck

Files

+ LICENSE view
@@ -0,0 +1,22 @@+Copyright (c) 2012, Gregory Crosswhite+All rights reserved.++Redistribution and use in source and binary forms, with or without modification,+are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright notice,+      this list of conditions and the following disclaimer.+    * Redistributions in binary form must reproduce the above copyright notice,+      this list of conditions and the following disclaimer in the documentation+      and/or other materials provided with the distribution.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ Test/Framework/Skip.hs view
@@ -0,0 +1,43 @@+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE MultiParamTypeClasses #-}++module Test.Framework.Skip+    ( skip+    , skipTestCase+    , skipTestGroup+    , skipTestProperty+    ) where++import Control.Arrow (first)+import Test.Framework.Providers.API ((:~>)(..),Test(..),Testlike(..),TestResultlike(..))+import Data.Typeable (Typeable)++data Skip = Skip deriving (Typeable)++instance Show Skip where show _ = "skipped"++instance TestResultlike Skip Skip where+    testSucceeded _ = True++instance Testlike Skip Skip Skip where+    runTest _ _ = return (Finished Skip,return ())+    testTypeName _ = "Skipped"++-- | Causes the given test or test suite to be skipped, though it will still show up as being "skipped" when the suite is run.  If given a test suite, 'skip' recursively applies it itself to the child tests and suites, all of which (except for the groups) will show up as being 'skipped' when the test suite is run.+skip :: Test -> Test+skip (Test name _) = Test name Skip+skip (TestGroup name tests) = TestGroup name (map skip tests)+skip (PlusTestOptions options test) = PlusTestOptions options (skip test)+skip (BuildTestBracketed bracket) = BuildTestBracketed (fmap (first skip) bracket)++-- | Instead of using the 'skip' function, you can change 'testCase' to 'skipTestCase' to cause the test to be skipped.+skipTestCase :: String -> a -> Test+skipTestCase name _ = Test name Skip++-- | Instead of using the 'skip' function, you can change 'testGroup' to 'skipTestGroup' to cause the test suite to be skipped.+skipTestGroup :: String -> [Test] -> Test+skipTestGroup name = TestGroup name . map skip++-- | Instead of using the 'skip' function, you can change 'testProperty' to 'skipTestProperty' to cause the test to be skipped.  (Note that this work regardless of whether you are using QuickCheck or SmallCheck for this particular test.)+skipTestProperty :: String -> a -> Test+skipTestProperty = skipTestCase
+ test-framework-skip.cabal view
@@ -0,0 +1,42 @@+Name:          test-framework-skip+Version:       1.0+Cabal-Version: >= 1.8+Category:      Testing+Synopsis:      Functions for conveniently marking some of the tests in a suite as being skipped.+Description:   When tracking down a problem it can often be useful to temporarily disable+               some or many of the tests in a suite so that one can focus on the problematic+               tests.  Rather than using a mess of comments, this module provides a+               function 'skip' (and a few variants) that causses a test or an entire test+               suite to be skipped - specifically, they will still show up in the suite+               as being 'skipped', but they will not be run.+License:       BSD3+License-File:  LICENSE+Author:        Gregory Crosswhite <gcrosswhite@gmail.com>+Maintainer:    Gregory Crosswhite <gcrosswhite@gmail.com>+Build-Type:    Simple++Source-Repository head+  Type:                git+  Location:            git://github.com/gcross/test-framework-skip.git++Library+    Build-Depends:+        base >= 3 && < 5,+        test-framework >= 0.8 && < 1.0+    Exposed-Modules:+        Test.Framework.Skip+    GHC-Options: -Wall++Test-Suite tests+    Type: exitcode-stdio-1.0+    Main-is: tests.hs+    Build-depends:+        test-framework-skip,+        base >= 3 && < 5,+        HUnit == 1.2.*,+        QuickCheck >= 2.4 && < 2.6,+        smallcheck == 1.0.*,+        test-framework >= 0.8 && < 1.0,+        test-framework-hunit >= 0.2 && < 0.4,+        test-framework-quickcheck2 >= 0.2 && < 0.4,+        test-framework-smallcheck == 0.2.*
+ tests.hs view
@@ -0,0 +1,35 @@+{-# LANGUAGE ScopedTypeVariables #-}++import Data.List (sort)++import Test.Framework+import Test.Framework.Skip+import Test.Framework.Providers.HUnit+import qualified Test.Framework.Providers.QuickCheck2 as Q+import qualified Test.Framework.Providers.SmallCheck as S+import Test.HUnit++main = defaultMain+    [testGroup "skip"+        [skip $ testCase "testCase" $ assertBool "This is totally going to fail..." False+        ,skip $ testGroup "testGroup"+            [testCase "child testCase" $ error "Did I do that?"+            ,Q.testProperty "child testProperty (quickcheck)" (\(x :: Int) -> x * 0 == x)+            ,S.testProperty "child testProperty (smallcheck)" (\(x :: Int) -> x * 0 == x)+            ]+        ,skip $ Q.testProperty "testProperty (quickcheck)" (\(x :: [Int]) -> x == sort x)+        ,skip $ S.testProperty "testProperty (smallcheck)" (\(x :: [Int]) -> x == sort x)+        ]+    ,skipTestCase "skipTestCase" $ assertFailure "Uh oh, I failed!"+    ,skipTestGroup "skipTestGroup"+        [testCase "child testCase" $ assertFailure "I would be so ashamed if somebody noticed me failing!"+        ,Q.testProperty "child testProperty (quickcheck)" False+        ,S.testProperty "child testProperty (smallcheck)" False+        ,testGroup "child testGroup"+            [Q.testProperty "grandchild testProperty (quickcheck)" False+            ,S.testProperty "grandchild testProperty (smallcheck)" False+            ,testCase "grandchild testCase" $ False @?= True+            ]+        ]+    ,skipTestProperty "skipTestProperty" (\(x :: Int) -> x /= x)+    ]