Permalink
Browse files

Fix test output of even more tests

  • Loading branch information...
1 parent 5aadbbb commit c812e17792d0c99d0a4d651ab7ccc9e302547bb1 @tibbe tibbe committed Sep 26, 2012
@@ -14,13 +14,8 @@ suite :: Version -> Test
suite cabalVersion = TestCase $ do
let spec = PackageSpec ("PackageTests" </> "BuildDeps" </> "InternalLibrary0") []
result <- cabal_build spec
- do
- assertEqual "cabal build should fail" False (successful result)
- when (cabalVersion >= Version [1, 7] []) $ do
- let sb = "library which is defined within the same package."
- -- In 1.7 it should tell you how to enable the desired behaviour.
- assertEqual ("cabal output should say "++show sb) True $
- sb `isInfixOf` (intercalate " " $ lines $ outputText result)
- `catch` \exc -> do
- putStrLn $ "Cabal result was "++show result
- throwIO (exc :: SomeException)
+ assertBuildFailed result
+ when (cabalVersion >= Version [1, 7] []) $ do
+ let sb = "library which is defined within the same package."
+ -- In 1.7 it should tell you how to enable the desired behaviour.
+ assertOutputContains sb result
@@ -11,8 +11,4 @@ suite :: Test
suite = TestCase $ do
let spec = PackageSpec ("PackageTests" </> "BuildDeps" </> "InternalLibrary1") []
result <- cabal_build spec
- do
- assertEqual "cabal build should succeed - see test-log.txt" True (successful result)
- `catch` \exc -> do
- putStrLn $ "Cabal result was "++show result
- throwIO (exc :: SomeException)
+ assertBuildSucceeded result
@@ -15,17 +15,9 @@ suite = TestCase $ do
unregister "InternalLibrary2"
iResult <- cabal_install specTI
- do
- assertEqual "cabal install should succeed" True (successful iResult)
- `catch` \exc -> do
- putStrLn $ "Cabal result was "++show iResult
- throwIO (exc :: SomeException)
+ assertInstallSucceeded iResult
bResult <- cabal_build spec
- do
- assertEqual "cabal build should succeed" True (successful bResult)
- `catch` \exc -> do
- putStrLn $ "Cabal result was "++show bResult
- throwIO (exc :: SomeException)
+ assertBuildSucceeded bResult
unregister "InternalLibrary2"
(_, _, output) <- run (Just $ directory spec) "dist/build/lemon/lemon" []
@@ -15,17 +15,9 @@ suite = TestCase $ do
unregister "InternalLibrary3"
iResult <- cabal_install specTI
- do
- assertEqual "cabal install should succeed - see to-install/test-log.txt" True (successful iResult)
- `catch` \exc -> do
- putStrLn $ "Cabal result was "++show iResult
- throwIO (exc :: SomeException)
+ assertInstallSucceeded iResult
bResult <- cabal_build spec
- do
- assertEqual "cabal build should succeed - see test-log.txt" True (successful bResult)
- `catch` \exc -> do
- putStrLn $ "Cabal result was "++show bResult
- throwIO (exc :: SomeException)
+ assertBuildSucceeded bResult
unregister "InternalLibrary3"
(_, _, output) <- run (Just $ directory spec) "dist/build/lemon/lemon" []
@@ -15,17 +15,9 @@ suite = TestCase $ do
unregister "InternalLibrary4"
iResult <- cabal_install specTI
- do
- assertEqual "cabal install should succeed - see to-install/test-log.txt" True (successful iResult)
- `catch` \exc -> do
- putStrLn $ "Cabal result was "++show iResult
- throwIO (exc :: SomeException)
+ assertInstallSucceeded iResult
bResult <- cabal_build spec
- do
- assertEqual "cabal build should succeed - see test-log.txt" True (successful bResult)
- `catch` \exc -> do
- putStrLn $ "Cabal result was "++show bResult
- throwIO (exc :: SomeException)
+ assertBuildSucceeded bResult
unregister "InternalLibrary4"
(_, _, output) <- run (Just $ directory spec) "dist/build/lemon/lemon" []
@@ -10,7 +10,10 @@ module PackageTests.PackageTester (
unregister,
run,
assertBuildSucceeded,
- assertTestSucceeded
+ assertBuildFailed,
+ assertTestSucceeded,
+ assertInstallSucceeded,
+ assertOutputContains
) where
import qualified Control.Exception.Extensible as E
@@ -188,8 +191,28 @@ assertBuildSucceeded result = unless (successful result) $
"expected: \'setup build\' should succeed\n" ++
" output: " ++ outputText result
+assertBuildFailed :: Result -> Assertion
+assertBuildFailed result = when (successful result) $
+ assertFailure $
+ "expected: \'setup build\' should fail\n" ++
+ " output: " ++ outputText result
+
assertTestSucceeded :: Result -> Assertion
assertTestSucceeded result = unless (successful result) $
assertFailure $
"expected: \'setup test\' should succeed\n" ++
" output: " ++ outputText result
+
+assertInstallSucceeded :: Result -> Assertion
+assertInstallSucceeded result = unless (successful result) $
+ assertFailure $
+ "expected: \'setup install\' should succeed\n" ++
+ " output: " ++ outputText result
+
+assertOutputContains :: String -> Result -> Assertion
+assertOutputContains needle result =
+ unless (needle `isInfixOf` (intercalate " " $ lines output)) $
+ assertFailure $
+ " expected: " ++ needle ++
+ "in output: " ++ output
+ where output = outputText result

0 comments on commit c812e17

Please sign in to comment.