From d3d781b598373490ca4810d4c9fe47e79aa88402 Mon Sep 17 00:00:00 2001 From: Mikhail Glushenkov <mikhail.glushenkov@gmail.com> Date: Sun, 28 Feb 2016 15:04:37 +0100 Subject: [PATCH] Test suite: print actual output in more cases. See https://github.com/haskell/cabal/pull/3197#issuecomment-189839042. --- Cabal/tests/PackageTests/Tests.hs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Cabal/tests/PackageTests/Tests.hs b/Cabal/tests/PackageTests/Tests.hs index a91b5d4945..6ca65322dd 100644 --- a/Cabal/tests/PackageTests/Tests.hs +++ b/Cabal/tests/PackageTests/Tests.hs @@ -112,11 +112,10 @@ tests config = do tc "BuildDeps/TargetSpecificDeps1" $ do cabal "configure" [] r <- shouldFail $ cabal' "build" [] - assertBool "error should be in MyLibrary.hs" $ - resultOutput r =~ "^MyLibrary.hs:" - assertBool - "error should be \"Could not find module `Text\\.PrettyPrint\"" $ - resultOutput r =~ "Could not find module.*Text\\.PrettyPrint" + assertRegex "error should be in MyLibrary.hs" "^MyLibrary.hs:" r + assertRegex + "error should be \"Could not find module `Text\\.PrettyPrint\"" + "Could not find module.*Text\\.PrettyPrint" r -- This is a control on TargetSpecificDeps1; it should -- succeed. @@ -128,11 +127,10 @@ tests config = do tc "BuildDeps/TargetSpecificDeps3" $ do cabal "configure" [] r <- shouldFail $ cabal' "build" [] - assertBool "error should be in lemon.hs" $ - resultOutput r =~ "^lemon.hs:" - assertBool - "error should be \"Could not find module `Text\\.PrettyPrint\"" $ - resultOutput r =~ "Could not find module.*Text\\.PrettyPrint" + assertRegex "error should be in lemon.hs" "^lemon.hs:" r + assertRegex + "error should be \"Could not find module `Text\\.PrettyPrint\"" + "Could not find module.*Text\\.PrettyPrint" r -- Test that Paths module is generated and available for executables. tc "PathsModule/Executable" $ cabal_build [] @@ -288,5 +286,10 @@ tests config = do ("foo foo myLibFunc " ++ expect) (concatOutput (resultOutput r)) + assertRegex :: String -> String -> Result -> TestM () + assertRegex msg regex r = let out = resultOutput r + in assertBool (msg ++ ",\nactual output:\n" ++ out) + (out =~ regex) + tc :: FilePath -> TestM a -> TestTreeM () tc name = testTree config name Nothing -- GitLab