packages feed

HUnit 1.2.4.2 → 1.2.4.3

raw patch · 6 files changed

+264/−131 lines, 6 filesdep +deepseqnew-component:exe:optimize-testsPVP ok

version bump matches the API change (PVP)

Dependencies added: deepseq

API changes (from Hackage documentation)

Files

HUnit.cabal view
@@ -1,5 +1,5 @@ Name:                   HUnit-Version:                1.2.4.2+Version:                1.2.4.3 Cabal-Version:          >= 1.6 License:                BSD3 License-File:           LICENSE@@ -13,15 +13,15 @@     HUnit is a unit testing framework for Haskell, inspired by the     JUnit tool for Java, see: <http://www.junit.org>. Tested-With:-    GHC == 6.12.3-    GHC == 7.0.3+    GHC == 7.0.4+    GHC == 7.4.1 Build-Type:             Custom Extra-Source-Files:+    HUnit.cabal.tests     tests/HUnitTest98.lhs     tests/HUnitTestBase.lhs     tests/HUnitTestExtended.lhs-    tests/HUnitTests.cabal-    tests/Setup.hs+    tests/HUnitTestOptimize.hs     tests/TerminalTest.lhs Data-Files:     doc/Guide.html@@ -36,15 +36,17 @@ flag base4  Library-    Build-Depends: base <5+    Build-Depends: +        base < 5,+        deepseq     if flag(base4)-        Build-Depends: base >=4+        Build-Depends: base >= 4         CPP-Options: -DBASE4         GHC-Options: -Wall     else-        Build-Depends: base <4+        Build-Depends: base < 4     if impl(ghc >= 6.10)-        Build-Depends: base >=4+        Build-Depends: base >= 4     Exposed-Modules:         Test.HUnit.Base,         Test.HUnit.Lang,@@ -56,93 +58,63 @@ Executable basic-tests     Main-Is:            HUnitTest98.lhs     HS-Source-Dirs:     . tests-    Build-Depends:      base<5+    Build-Depends: +        base < 5,+        deepseq     if flag(base4)-        Build-Depends: base >=4+        Build-Depends: base >= 4         CPP-Options: -DBASE4         GHC-Options: -Wall     else-        Build-Depends: base <4+        Build-Depends: base < 4     if impl(ghc >= 6.10)-        Build-Depends: base >=4+        Build-Depends: base >= 4         Extensions: CPP  Executable extended-tests     Main-Is:            HUnitTestExtended.lhs     HS-Source-Dirs:     . tests-    Build-Depends:      base<5+    Build-Depends: +        base < 5,+        deepseq     if flag(base4)-        Build-Depends: base >=4+        Build-Depends: base >= 4         CPP-Options: -DBASE4         GHC-Options: -Wall     else-        Build-Depends: base <4+        Build-Depends: base < 4     if impl(ghc >= 6.10)-        Build-Depends: base >=4+        Build-Depends: base >= 4         Extensions: CPP  Executable terminal-tests     Main-Is:            TerminalTest.lhs     HS-Source-Dirs:     . tests-    Build-Depends:      base<5+    Build-Depends: +        base < 5,+        deepseq     if flag(base4)-        Build-Depends: base >=4+        Build-Depends: base >= 4         CPP-Options: -DBASE4     else-        Build-Depends: base <4+        Build-Depends: base < 4     if impl(ghc >= 6.10)-        Build-Depends: base >=4+        Build-Depends: base >= 4         Extensions: CPP---- Commenting these tests out because Hackage doesn't--- accept packages that specify optimization level,--- which is a key component of these tests.---Executable optimize-0-tests---    Main-Is:            HUnitTestOptimize.hs---    HS-Source-Dirs:     . tests---    Build-Depends:      base<5---    GHC-Options:        -O0---    if flag(base4)---        Build-Depends: base >=4---        CPP-Options: -DBASE4---        GHC-Options: -Wall---    else---        Build-Depends: base <4---    if impl(ghc >= 6.10)---        Build-Depends: base >=4---        Extensions: CPP         -Executable optimize-1-tests+Executable optimize-tests     Main-Is:            HUnitTestOptimize.hs     HS-Source-Dirs:     . tests-    Build-Depends:      base<5--- Commenting out this line because, at the time of writing, -O1 is implied and--- the issue, that tests are optimized out of existence, is exposed at this --- optimization level.---    GHC-Options:        -O1+    Build-Depends: +        base < 5,+        deepseq     if flag(base4)-        Build-Depends: base >=4+        Build-Depends: base >= 4         CPP-Options: -DBASE4         GHC-Options: -Wall     else-        Build-Depends: base <4+        Build-Depends: base < 4     if impl(ghc >= 6.10)-        Build-Depends: base >=4+        Build-Depends: base >= 4         Extensions: CPP-        --- Commented out for the same reason as optimize-0-tests.---Executable optimize-2-tests---    Main-Is:            HUnitTestOptimize.hs---    HS-Source-Dirs:     . tests---    Build-Depends:      base<5---    GHC-Options:        -O2---    if flag(base4)---        Build-Depends: base >=4---        CPP-Options: -DBASE4---        GHC-Options: -Wall---    else---        Build-Depends: base <4---    if impl(ghc >= 6.10)---        Build-Depends: base >=4---        Extensions: CPP         
+ HUnit.cabal.tests view
@@ -0,0 +1,160 @@+-- This CABAL file is used to build and run all of the various tests for the +-- project.  This separate file is necessary because Hackage does not allow+-- the optimization level to be specified when building executables and some+-- tests require different optimization levels to be set.+--+-- To use this file, simply copy it to HUnit.cabal, then build as normal.  You+-- may rename the existing version of HUnit.cabal first, if you like.+Name:                   HUnit+Version:                1.2.4.3+Cabal-Version:          >= 1.6+License:                BSD3+License-File:           LICENSE+Author:                 Dean Herington+Maintainer:             hunit@richardg.name+Stability:              stable+Homepage:               http://hunit.sourceforge.net/+Category:               Testing+Synopsis:               A unit testing framework for Haskell+Description:+    HUnit is a unit testing framework for Haskell, inspired by the+    JUnit tool for Java, see: <http://www.junit.org>.+Tested-With:+    GHC == 7.0.4+    GHC == 7.4.1+Build-Type:             Custom+Extra-Source-Files:+    tests/HUnitTest98.lhs+    tests/HUnitTestBase.lhs+    tests/HUnitTestExtended.lhs+    tests/HUnitTestOptimize.hs+    tests/TerminalTest.lhs+Data-Files:+    doc/Guide.html+    examples/Example.hs+    prologue.txt+    README+source-repository head+    type:     darcs+    location: http://code.haskell.org/HUnit/++flag base4++Library+    Build-Depends: +        base < 5,+        deepseq+    if flag(base4)+        Build-Depends: base >= 4+        CPP-Options: -DBASE4+        GHC-Options: -Wall+    else+        Build-Depends: base < 4+    if impl(ghc >= 6.10)+        Build-Depends: base >= 4+    Exposed-Modules:+        Test.HUnit.Base,+        Test.HUnit.Lang,+        Test.HUnit.Terminal,+        Test.HUnit.Text,+        Test.HUnit+    Extensions: CPP++Executable basic-tests+    Main-Is:            HUnitTest98.lhs+    HS-Source-Dirs:     . tests+    Build-Depends: +        base < 5,+        deepseq+    if flag(base4)+        Build-Depends: base >= 4+        CPP-Options: -DBASE4+        GHC-Options: -Wall+    else+        Build-Depends: base < 4+    if impl(ghc >= 6.10)+        Build-Depends: base >= 4+        Extensions: CPP++Executable extended-tests+    Main-Is:            HUnitTestExtended.lhs+    HS-Source-Dirs:     . tests+    Build-Depends: +        base < 5,+        deepseq+    if flag(base4)+        Build-Depends: base >= 4+        CPP-Options: -DBASE4+        GHC-Options: -Wall+    else+        Build-Depends: base < 4+    if impl(ghc >= 6.10)+        Build-Depends: base >= 4+        Extensions: CPP++Executable terminal-tests+    Main-Is:            TerminalTest.lhs+    HS-Source-Dirs:     . tests+    Build-Depends: +        base < 5,+        deepseq+    if flag(base4)+        Build-Depends: base >= 4+        CPP-Options: -DBASE4+    else+        Build-Depends: base < 4+    if impl(ghc >= 6.10)+        Build-Depends: base >= 4+        Extensions: CPP++Executable optimize-0-tests+    Main-Is:            HUnitTestOptimize.hs+    HS-Source-Dirs:     . tests+    Build-Depends: +        base < 5,+        deepseq+    GHC-Options:        -O0+    if flag(base4)+        Build-Depends: base >= 4+        CPP-Options: -DBASE4 -DO0+        GHC-Options: -Wall+    else+        Build-Depends: base < 4+    if impl(ghc >= 6.10)+        Build-Depends: base >= 4+        Extensions: CPP+        +Executable optimize-1-tests+    Main-Is:            HUnitTestOptimize.hs+    HS-Source-Dirs:     . tests+    Build-Depends: +        base < 5,+        deepseq+    GHC-Options:        -O1+    if flag(base4)+        Build-Depends: base >= 4+        CPP-Options: -DBASE4 -DO1+        GHC-Options: -Wall+    else+        Build-Depends: base < 4+    if impl(ghc >= 6.10)+        Build-Depends: base >= 4+        Extensions: CPP+        +Executable optimize-2-tests+    Main-Is:            HUnitTestOptimize.hs+    HS-Source-Dirs:     . tests+    Build-Depends: +        base < 5,+        deepseq+    GHC-Options:        -O2+    if flag(base4)+        Build-Depends: base >= 4+        CPP-Options: -DBASE4 -DO2+        GHC-Options: -Wall+    else+        Build-Depends: base < 4+    if impl(ghc >= 6.10)+        Build-Depends: base >= 4+        Extensions: CPP+        
Test/HUnit/Lang.hs view
@@ -26,6 +26,7 @@ import System.IO.Error (ioeGetErrorString, try)
 #endif
 
+import Control.DeepSeq
 
 
 -- Interfaces
@@ -78,7 +79,7 @@ #ifdef BASE4
 instance Exception HUnitFailure
 
-assertFailure msg = E.throwIO (HUnitFailure msg)
+assertFailure msg = msg `deepseq` E.throwIO (HUnitFailure msg)
 
 performTestCase action = 
     do action
@@ -95,7 +96,7 @@ 
        E.Handler (\e -> return $ Just (False, show (e :: E.SomeException)))]
 #else
-assertFailure msg = E.throwDyn (HUnitFailure msg)
+assertFailure msg = msg `deepseq` E.throwDyn (HUnitFailure msg)
 
 performTestCase action = 
     do r <- E.try action
@@ -112,7 +113,7 @@ 
 nhc98Prefix = "I/O error (user-defined), call to function `userError':\n  "
 
-assertFailure msg = ioError (userError (hunitPrefix ++ msg))
+assertFailure msg = msg `deepseq` ioError (userError (hunitPrefix ++ msg))
 
 performTestCase action = do r <- try action
                             case r of Right () -> return Nothing
tests/HUnitTestOptimize.hs view
@@ -2,12 +2,30 @@ -- -- The purpose of this file is to test whether certain issues occur with optimization. -- It should be built and run with each level of optimization.  I.e., -O0, -O1, -O2+--+-- With some versions and optimization levels of HUnit and GHC, tests were getting+-- optimized out.  This is a very bad thing and needs to be tested for.  module Main (main) where  import Control.Monad (unless) import Test.HUnit +-- Used to include the optimization level in the test results+optimizationLevel :: String+#if defined(O0)+optimizationLevel = "-O0"+#elif defined(O1)+optimizationLevel = "-O1"+#elif defined(O2)+optimizationLevel = "-O2"+#else+optimizationLevel = "unknown optimization level"+#endif++-- A test runner that doesn't print the results of the tests; it only tabulates+-- the results of the tests.  In this context, it's used to verify that no+-- tests were optimized away or otherwise lost. simpleTestRunner :: Test -> IO Counts simpleTestRunner t = do      (counts', _) <- runTestText nullAccum t@@ -15,9 +33,12 @@     where         nullAccum = PutText (\ _ _ _ -> return ()) () -main :: IO Counts-main = do-    counts2 <- simpleTestRunner $ TestList [ +-- Some combinations of HUnit, GHC, and optimization levels cause tests to be+-- optimized away.  This section verifies that all tests of a type are+-- performed.+optimizationTests :: IO ()+optimizationTests = do+    counts2 <- simpleTestRunner $ TestLabel "Basic Optimization Tests" $ TestList [          True ~=? True,         False ~=? True,         TestCase $ assertEqual "both true" True True,@@ -27,10 +48,44 @@         TestCase $ (False @?= True),         TestCase $ unless (False == True) (assertFailure "f")         ]-    counts3 <- runTestTT $ TestList [-        TestCase $ assertEqual "Number of cases" (cases counts2) 8,-        TestCase $ assertEqual "Number of cases tried" (tried counts2) 8,-        TestCase $ assertEqual "Number of failures" (failures counts2) 6+    -- Verify results of counts2+    -- We can't use HUnit because it's possible that some tests have been+    -- optimized away, so we'll just do it manually.+    unless +        (cases counts2 == 8)+        (putStrLn $ "Failure: Basic Optimization (" ++ optimizationLevel ++ "): expected 8 test cases; only " ++ (show $ cases counts2) ++ " found.  Some may have been optimized out.")+    unless +        (tried counts2 == 8)+        (putStrLn $ "Failure: Basic Optimization (" ++ optimizationLevel ++ "): expected to try 8 test cases; only " ++ (show $ tried counts2) ++ " tried.  Some may have been optimized out.")+    unless +        (errors counts2 == 0)+        (putStrLn $ "Failure: Basic Optimization (" ++ optimizationLevel ++ "): expected 0 errors; " ++ (show $ errors counts2) ++ " found.")+    unless+        (failures counts2 == 6)+        (putStrLn $ "Failure: Basic Optimization (" ++ optimizationLevel ++ "): expected 6 failed cases; only " ++ (show $ failures counts2) ++ " failed.  Some may have been optimized out.")+    return ()++-- Added in 1.4.2.3+-- When certain errors occur in a list of tests, the subsequent tests in the+-- list weren't being run.  This test verifies that this does not happen.+undefinedSwallowsTests :: IO ()+undefinedSwallowsTests = do+    -- Added in 1.2.4.3 because the second test case will never be run+    -- (in prior versions)+    counts2 <- simpleTestRunner . TestList $ [+        TestCase $ ('f' : undefined) @?= "bar",+        TestCase $ "foo" @?= "bar"         ]-    putStrLn "There should be 3 cases, 3 tried, and 0 errors and 0 failures."-    return counts3+    _ <- runTestTT $ TestLabel ("Undefined Swallows Tests (" ++ optimizationLevel ++ ")") $ TestList [+        TestCase $ assertEqual "cases" (cases counts2) 2, +        TestCase $ assertEqual "tried" (tried counts2) 2, +        TestCase $ assertEqual "errors" (errors counts2) 1, +        TestCase $ assertEqual "failures" (failures counts2) 1+        ]+    return ()++-- A simple sequencer of the 2 tests+main :: IO ()+main = do+    optimizationTests+    undefinedSwallowsTests
− tests/HUnitTests.cabal
@@ -1,48 +0,0 @@-Name:                   HUnitTests-Version:                1.2.2.0-License:                BSD3-License-File:           LICENSE-Author:                 Dean Herington-Homepage:               http://hunit.sourceforge.net/-Category:               Testing-Synopsis:               A set of unit tests for HUnit--- Build-Type:             Simple--Executable:             basic-tests-Main-Is:                HUnitTest98.lhs-HS-Source-Dirs:         . ..--- Build-Depends:          base-Extensions:             CPP--Executable:             extended-tests-Main-Is:                HUnitTestExtended.lhs-HS-Source-Dirs:         . ..--- Build-Depends:          base-Extensions:             CPP--Executable:             terminal-tests-Main-Is:                TerminalTest.lhs-HS-Source-Dirs:         . ..--- Build-Depends:          base-Extensions:             CPP--Executable:             optimize-tests-O0-Main-Is:                HUnitTestOptimize.hs-HS-Source-Dirs:         . ..--- Build-Depends:          base-Extensions:             CPP-GHC-Options:            -O0--Executable:             optimize-tests-O1-Main-Is:                HUnitTestOptimize.hs-HS-Source-Dirs:         . ..--- Build-Depends:          base-Extensions:             CPP-GHC-Options:            -O1--Executable:             optimize-tests-O2-Main-Is:                HUnitTestOptimize.hs-HS-Source-Dirs:         . ..--- Build-Depends:          base-Extensions:             CPP-GHC-Options:            -O2
− tests/Setup.hs
@@ -1,7 +0,0 @@-#!/usr/bin/env runghc-module Main (main) where--import Distribution.Simple--main :: IO ()-main = defaultMain