Permalink
Browse files

More test output tweaks

  • Loading branch information...
1 parent 2c842a0 commit 5aadbbbf773a1a52dc2d536c0a04a19d88672a9b @tibbe tibbe committed Sep 26, 2012
@@ -17,5 +17,4 @@ checkBenchmark :: Version -> Test
checkBenchmark cabalVersion = TestCase $ do
let spec = PackageSpec dir ["--enable-benchmarks"]
buildResult <- cabal_build spec
- let buildMessage = "\'setup build\' should succeed"
- assertEqual buildMessage True $ successful buildResult
+ assertBuildSucceeded buildResult
@@ -8,7 +8,9 @@ module PackageTests.PackageTester (
cabal_bench,
cabal_install,
unregister,
- run
+ run,
+ assertBuildSucceeded,
+ assertTestSucceeded
) where
import qualified Control.Exception.Extensible as E
@@ -25,6 +27,7 @@ import Control.Monad
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as C
+import Test.HUnit
data PackageSpec =
@@ -177,3 +180,16 @@ record :: PackageSpec -> Result -> IO ()
record spec res = do
C.writeFile (directory spec </> "test-log.txt") (C.pack $ outputText res)
+-- Test helpers:
+
+assertBuildSucceeded :: Result -> Assertion
+assertBuildSucceeded result = unless (successful result) $
+ assertFailure $
+ "expected: \'setup build\' should succeed\n" ++
+ " output: " ++ outputText result
+
+assertTestSucceeded :: Result -> Assertion
+assertTestSucceeded result = unless (successful result) $
+ assertFailure $
+ "expected: \'setup test\' should succeed\n" ++
+ " output: " ++ outputText result
@@ -14,33 +14,23 @@ import PackageTests.PackageTester
dir :: FilePath
dir = "PackageTests" </> "TestSuiteExeV10"
-assertBuildSucceeds result =
- assertBool (msg ++ " (output: " ++ show result ++ ")") $
- successful result
- where msg = "\'setup build\' should succeed"
-
-assertTestSucceeds result =
- assertBool (msg ++ " (output: " ++ show result ++ ")") $
- successful result
- where msg = "\'cabal test\' should succeed"
-
checkTest :: Version -> Test
checkTest cabalVersion = TestCase $ do
let spec = PackageSpec dir ["--enable-tests"]
buildResult <- cabal_build spec
- assertBuildSucceeds buildResult
+ assertBuildSucceeded buildResult
testResult <- cabal_test spec []
- assertTestSucceeds testResult
+ assertTestSucceeded testResult
checkTestWithHpc :: Version -> Test
checkTestWithHpc cabalVersion = TestCase $ do
let spec = PackageSpec dir [ "--enable-tests"
, "--enable-library-coverage"
]
buildResult <- cabal_build spec
- assertBuildSucceeds buildResult
+ assertBuildSucceeded buildResult
testResult <- cabal_test spec []
- assertTestSucceeds testResult
+ assertTestSucceeded testResult
let dummy = emptyTestSuite { testName = "test-Foo" }
tixFile = tixFilePath (dir </> "dist") $ testName dummy
tixFileMessage = ".tix file should exist"

0 comments on commit 5aadbbb

Please sign in to comment.