diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2019-08-30 11:46:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-30 11:46:13 +0200 |
commit | 036c583ea243869f05a5a311c90b94943a2b635c (patch) | |
tree | aadee7988980544f84b83d808707080481568cc5 /tests/TestSuite | |
parent | 779fa66c7b1719e071dc3f4d38a4cc2feb9492c6 (diff) | |
download | hakyll-036c583ea243869f05a5a311c90b94943a2b635c.tar.gz |
Improve error messages
Diffstat (limited to 'tests/TestSuite')
-rw-r--r-- | tests/TestSuite/Util.hs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/TestSuite/Util.hs b/tests/TestSuite/Util.hs index fa411f8..2678fea 100644 --- a/tests/TestSuite/Util.hs +++ b/tests/TestSuite/Util.hs @@ -6,6 +6,7 @@ module TestSuite.Util , newTestProvider , testCompiler , testCompilerDone + , testCompilerError , testConfiguration , cleanTestEnv , renderParagraphs @@ -13,7 +14,7 @@ module TestSuite.Util -------------------------------------------------------------------------------- -import Data.List (intercalate) +import Data.List (intercalate, isInfixOf) import Data.Monoid (mempty) import qualified Data.Set as S import Test.Tasty @@ -80,13 +81,21 @@ testCompilerDone store provider underlying compiler = do CompilerDone x _ -> return x CompilerError e -> fail $ "TestSuite.Util.testCompilerDone: compiler " ++ show underlying ++ - " threw: " ++ intercalate "; " e + " threw: " ++ intercalate "; " (compilerErrorMessages e) CompilerRequire i _ -> fail $ "TestSuite.Util.testCompilerDone: compiler " ++ show underlying ++ " requires: " ++ show i CompilerSnapshot _ _ -> fail "TestSuite.Util.testCompilerDone: unexpected CompilerSnapshot" +testCompilerError :: Store -> Provider -> Identifier -> Compiler a -> String -> IO () +testCompilerError store provider underlying compiler expectedMessage = do + result <- testCompiler store provider underlying compiler + case result of + CompilerError e -> + any (expectedMessage `isInfixOf`) (compilerErrorMessages e) @? + "Expecting '" ++ expectedMessage ++ "' error" + _ -> assertFailure "Expecting CompilerError" -------------------------------------------------------------------------------- testConfiguration :: Configuration |