[commit: haddock] v2.14: Ignore version string during HTML tests. (4e9aa92)

git at git.haskell.org git at git.haskell.org
Fri Apr 11 18:04:05 UTC 2014


Repository : ssh://git@git.haskell.org/haddock

On branch  : v2.14
Link       : http://git.haskell.org/haddock.git/commitdiff/4e9aa92d769ea334867e621033ca27cd6a284d3a

>---------------------------------------------------------------

commit 4e9aa92d769ea334867e621033ca27cd6a284d3a
Author: Mateusz Kowalczyk <fuuzetsu at fuuzetsu.co.uk>
Date:   Fri Apr 11 18:47:41 2014 +0100

    Ignore version string during HTML tests.


>---------------------------------------------------------------

4e9aa92d769ea334867e621033ca27cd6a284d3a
 html-test/run.lhs |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/html-test/run.lhs b/html-test/run.lhs
index e4c83da..153ab32 100755
--- a/html-test/run.lhs
+++ b/html-test/run.lhs
@@ -134,9 +134,21 @@ check modules strict = do
       else do
         putStrLn $ "Pass: " ++ mod ++ " (no .ref file)"
 
+-- | A rather nasty way to drop the Haddock version string from the
+-- end of the generated HTML files so that we don't have to change
+-- every single test every time we change versions. We rely on the the
+-- last paragraph of the document to be the version. We end up with
+-- malformed HTML but we don't care as we never look at it ourselves.
+dropVersion :: String -> String
+dropVersion = reverse . dropTillP . reverse
+  where
+    dropTillP [] = []
+    dropTillP ('p':'<':xs) = xs
+    dropTillP (_:xs) = dropTillP xs
 
 haddockEq :: String -> String -> Bool
-haddockEq file1 file2 = stripLinks file1 == stripLinks file2
+haddockEq file1 file2 =
+  stripLinks (dropVersion file1) == stripLinks (dropVersion file2)
 
 stripLinks :: String -> String
 stripLinks str =



More information about the ghc-commits mailing list