From 7d8ece225e5387d0d08a675bda82bd2a1af5a173 Mon Sep 17 00:00:00 2001 From: Mateusz Kowalczyk Date: Thu, 26 Mar 2015 19:29:25 +0000 Subject: Test for anchor defaulting I delete the old tests because it turns out that: * test runner would never put them in scope of each other even with imports so just one would suffice * test runner actually needed some hacking to keep links so in the end we would end up with no anchors making them useless --- html-test/ref/Bug253.html | 99 ++++++++++++++++++++++++++++++++++++ html-test/ref/Ticket253_1.html | 91 --------------------------------- html-test/ref/Ticket253_2.html | 111 ----------------------------------------- html-test/run.lhs | 24 ++++++--- html-test/src/Bug253.hs | 10 ++++ html-test/src/Ticket253_1.hs | 6 --- html-test/src/Ticket253_2.hs | 6 --- 7 files changed, 126 insertions(+), 221 deletions(-) create mode 100644 html-test/ref/Bug253.html delete mode 100644 html-test/ref/Ticket253_1.html delete mode 100644 html-test/ref/Ticket253_2.html create mode 100644 html-test/src/Bug253.hs delete mode 100644 html-test/src/Ticket253_1.hs delete mode 100644 html-test/src/Ticket253_2.hs (limited to 'html-test') diff --git a/html-test/ref/Bug253.html b/html-test/ref/Bug253.html new file mode 100644 index 00000000..0802d91e --- /dev/null +++ b/html-test/ref/Bug253.html @@ -0,0 +1,99 @@ + +Bug253

 

Safe HaskellSafe

Bug253

Description

This module tests that if we're trying to link to a qualified + identifier that's not in scope, we get an anchor as if it was a + variable. Previous behaviour was to treat it as a type constructor + so issue like #253 arose. Also see rename function comments in + source.

Synopsis

Documentation

foo :: ()

This link should generate #v anchor: fakeFakeFake

diff --git a/html-test/ref/Ticket253_1.html b/html-test/ref/Ticket253_1.html deleted file mode 100644 index ade128e9..00000000 --- a/html-test/ref/Ticket253_1.html +++ /dev/null @@ -1,91 +0,0 @@ - -Ticket253_1

 

Safe HaskellSafe

Ticket253_1

Synopsis

Documentation

foo :: Int

See bar.

Also see Baz

diff --git a/html-test/ref/Ticket253_2.html b/html-test/ref/Ticket253_2.html deleted file mode 100644 index 0b03a874..00000000 --- a/html-test/ref/Ticket253_2.html +++ /dev/null @@ -1,111 +0,0 @@ - -Ticket253_2

 

Safe HaskellSafe

Ticket253_2

Synopsis

Documentation

bar :: Int

Comment

data Baz

Constructors

Baz 
diff --git a/html-test/run.lhs b/html-test/run.lhs index a80b265e..1f19b723 100755 --- a/html-test/run.lhs +++ b/html-test/run.lhs @@ -21,7 +21,6 @@ import System.Exit import System.FilePath import System.Process (ProcessHandle, runProcess, waitForProcess, system) - packageRoot, dataDir, haddockPath, baseDir, testDir, outDir :: FilePath baseDir = takeDirectory __FILE__ testDir = baseDir "src" @@ -112,11 +111,11 @@ check modules strict = do then do out <- readFile outfile ref <- readFile reffile - if not $ haddockEq out ref + if not $ haddockEq (outfile, out) (reffile, ref) then do putStrLn $ "Output for " ++ mod ++ " has changed! Exiting with diff:" - let ref' = stripLinks ref - out' = stripLinks out + let ref' = maybeStripLinks outfile ref + out' = maybeStripLinks reffile out let reffile' = outDir takeFileName reffile ++ ".nolinks" outfile' = outDir takeFileName outfile ++ ".ref.nolinks" writeFile reffile' ref' @@ -134,6 +133,10 @@ check modules strict = do else do putStrLn $ "Pass: " ++ mod ++ " (no .ref file)" +-- | List of modules in which we don't 'stripLinks' +preserveLinksModules :: [String] +preserveLinksModules = map (++ ".html") ["Bug253"] + -- | 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 @@ -146,9 +149,16 @@ dropVersion = reverse . dropTillP . reverse dropTillP ('p':'<':xs) = xs dropTillP (_:xs) = dropTillP xs -haddockEq :: String -> String -> Bool -haddockEq file1 file2 = - stripLinks (dropVersion file1) == stripLinks (dropVersion file2) +haddockEq :: (FilePath, String) -> (FilePath, String) -> Bool +haddockEq (fn1, file1) (fn2, file2) = + maybeStripLinks fn1 (dropVersion file1) + == maybeStripLinks fn2 (dropVersion file2) + +maybeStripLinks :: String -- ^ Module we're considering for stripping + -> String -> String +maybeStripLinks m = if any (`isSuffixOf` m) preserveLinksModules + then id + else stripLinks stripLinks :: String -> String stripLinks str = diff --git a/html-test/src/Bug253.hs b/html-test/src/Bug253.hs new file mode 100644 index 00000000..499f6cd4 --- /dev/null +++ b/html-test/src/Bug253.hs @@ -0,0 +1,10 @@ +-- | This module tests that if we're trying to link to a /qualified/ +-- identifier that's not in scope, we get an anchor as if it was a +-- variable. Previous behaviour was to treat it as a type constructor +-- so issue like #253 arose. Also see @rename@ function comments in +-- source. +module Bug253 where + +-- | This link should generate @#v@ anchor: 'DoesNotExist.fakeFakeFake' +foo :: () +foo = () diff --git a/html-test/src/Ticket253_1.hs b/html-test/src/Ticket253_1.hs deleted file mode 100644 index 62ab4b17..00000000 --- a/html-test/src/Ticket253_1.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Ticket253_1 where --- | See 'Ticket253_2.bar'. --- --- Also see 'Ticket253_2.Baz' -foo :: Int -foo = 0 diff --git a/html-test/src/Ticket253_2.hs b/html-test/src/Ticket253_2.hs deleted file mode 100644 index a19d4cee..00000000 --- a/html-test/src/Ticket253_2.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Ticket253_2 where --- | Comment -bar :: Int -bar = 0 - -data Baz = Baz -- cgit v1.2.3