MuCheck-HUnit (empty) → 0.2.0.0
raw patch · 6 files changed
+99/−0 lines, 6 filesdep +HUnitdep +MuCheckdep +basesetup-changed
Dependencies added: HUnit, MuCheck, base
Files
- LICENSE +0/−0
- MuCheck-HUnit.cabal +40/−0
- Setup.hs +3/−0
- changes.md +0/−0
- src/Main.hs +23/−0
- src/Test/MuCheck/TestAdapter/HUnit.hs +33/−0
+ LICENSE view
+ MuCheck-HUnit.cabal view
@@ -0,0 +1,40 @@+name: MuCheck-HUnit+version: 0.2.0.0+synopsis: Automated Mutation Testing for HUnit tests+description: This package contains the test adapter for HUnit tests to use it with MuCheck+homepage: https://bitbucket.com/osu-testing/mucheck-hunit+license: GPL-2+license-file: LICENSE+author: Rahul Gopinath <rahul@gopinath.org>+maintainer: rahul@gopinath.org+category: Testing+build-type: Simple+cabal-version: >= 1.10+extra-source-files: changes.md++source-repository head+ type: git+ location: https://bitbucket.org/osu-testing/mucheck-hunit.git++source-repository this+ type: git+ location: https://bitbucket.org/osu-testing/mucheck-hunit.git+ tag: 0.2.0.0++executable mucheck-hunit+ build-depends: base >=4 && <5,+ HUnit>=1.0,+ MuCheck== 0.2.0.*+ default-language: Haskell2010+ hs-source-dirs: src+ main-is: Main.hs+ ghc-options: -Wall -fno-warn-orphans++library+ exposed-modules: Test.MuCheck.TestAdapter.HUnit+ build-depends: base >=4 && <5,+ HUnit>=1.0,+ MuCheck==0.2.0.*+ default-language: Haskell2010+ hs-source-dirs: src+
+ Setup.hs view
@@ -0,0 +1,3 @@+import Distribution.Simple++main = defaultMain
+ changes.md view
+ src/Main.hs view
@@ -0,0 +1,23 @@+module Main where+import System.Environment (getArgs, withArgs)+import Control.Monad (void)++import Test.MuCheck (mucheck)+import Test.MuCheck.TestAdapter.HUnit+import Test.MuCheck.TestAdapter+import Test.MuCheck.Utils.Print++main :: IO ()+main = do+ val <- getArgs+ case val of+ ("-h" : _ ) -> help+ (fn : file : modulename : args) -> withArgs [] $ mucheck tsFn fn file modulename args+ _ -> error "Need function file modulename [args]\n\tUse -h to get help"+ where tsFn :: [MutantFilename] -> [InterpreterOutput HUnitSummary] -> Summary+ tsFn = testSummary+++help :: IO ()+help = putStrLn $ "mucheck function file modulename [args]\n" ++ showAS ["E.g:",+ " mucheck-hunit qsort Examples/HUnitTest.hs Examples.HUnitTest 'runTestTT tests'", ""]
+ src/Test/MuCheck/TestAdapter/HUnit.hs view
@@ -0,0 +1,33 @@+{-# LANGUAGE StandaloneDeriving, DeriveDataTypeable, TypeSynonymInstances #-}+-- | Module for using HUnit tests+module Test.MuCheck.TestAdapter.HUnit where+import qualified Test.HUnit as HUnit+import Test.MuCheck.TestAdapter+import Test.MuCheck.Utils.Print (showA, showAS)++import Data.Typeable+import Data.List((\\))+import Data.Either (partitionEithers)++deriving instance Typeable HUnit.Counts+type HUnitSummary = HUnit.Counts++-- | Summarizable instance of `HUnitSumary`+instance Summarizable HUnitSummary where+ testSummary mutantFiles results = Summary logMsg+ where (loadingErrorCases, executedCases) = partitionEithers results+ loadingErrorFiles = mutantFiles \\ map fst executedCases+ successCases = filter (isSuccess . snd) executedCases+ failuresCases = filter (isFailure . snd) executedCases+ runningErrorCases = filter ((>0) . HUnit.errors . snd) executedCases \\ failuresCases+ failToFullyTryCases = filter ((\c -> HUnit.cases c > HUnit.tried c) . snd) executedCases+ logMsg = showAS ["Details:",+ "Loading error files:",showA loadingErrorFiles,+ "Loading error messages:",showA loadingErrorCases,+ "Successes:", showA successCases,+ "Failures:", showA failuresCases,+ "Error while running:", showA runningErrorCases,+ "Incompletely tested (may include failures and running errors):",showA failToFullyTryCases]+ isSuccess c = (HUnit.cases c == HUnit.tried c) && HUnit.failures c == 0 && HUnit.errors c == 0+ isFailure c = HUnit.failures c > 0+