From 554db03b637a76a01f2907d3115ef0dc290234c5 Mon Sep 17 00:00:00 2001 From: Ɓukasz Hanuszczak Date: Fri, 14 Aug 2015 20:05:37 +0200 Subject: Create convenience script for running specific HTML tests. --- haddock.cabal | 4 ++-- html-test/Main.hs | 38 ++++++++++++++++++++++++++++++++++++++ html-test/run | 5 +++++ html-test/run.hs | 38 -------------------------------------- 4 files changed, 45 insertions(+), 40 deletions(-) create mode 100755 html-test/Main.hs create mode 100755 html-test/run delete mode 100755 html-test/run.hs diff --git a/haddock.cabal b/haddock.cabal index c0e812a1..019f235e 100644 --- a/haddock.cabal +++ b/haddock.cabal @@ -125,9 +125,9 @@ executable haddock test-suite html-test type: exitcode-stdio-1.0 default-language: Haskell2010 - main-is: run.hs + main-is: Main.hs hs-source-dirs: html-test - build-depends: base, directory, process, filepath, Cabal, xml, syb, haddock-test + build-depends: base, filepath, haddock-test test-suite hypsrc-test type: exitcode-stdio-1.0 diff --git a/html-test/Main.hs b/html-test/Main.hs new file mode 100755 index 00000000..8d1b40a8 --- /dev/null +++ b/html-test/Main.hs @@ -0,0 +1,38 @@ +{-# LANGUAGE CPP #-} + + +import System.Environment +import System.FilePath + +import Test.Haddock +import Test.Haddock.Xhtml + + +checkConfig :: CheckConfig Xhtml +checkConfig = CheckConfig + { ccfgRead = \mdl input -> stripIfRequired mdl <$> parseXhtml input + , ccfgDump = dumpXhtml + , ccfgEqual = (==) + } + + +dirConfig :: DirConfig +dirConfig = defaultDirConfig $ takeDirectory __FILE__ + + +main :: IO () +main = runAndCheck =<< parseArgs checkConfig dirConfig =<< getArgs + + +stripIfRequired :: String -> Xhtml -> Xhtml +stripIfRequired mdl = + stripLinks' . stripFooter + where + stripLinks' + | mdl `elem` preserveLinksModules = id + | otherwise = stripLinks + + +-- | List of modules in which we don't 'stripLinks' +preserveLinksModules :: [String] +preserveLinksModules = ["Bug253"] diff --git a/html-test/run b/html-test/run new file mode 100755 index 00000000..5e17ad0f --- /dev/null +++ b/html-test/run @@ -0,0 +1,5 @@ +#!/bin/bash + +export HADDOCK_PATH=$(which haddock) +LIB_PATH="$(dirname "$BASH_SOURCE")/../haddock-test/src/" +runhaskell -i:"$LIB_PATH" "Main.hs" $@ diff --git a/html-test/run.hs b/html-test/run.hs deleted file mode 100755 index 8d1b40a8..00000000 --- a/html-test/run.hs +++ /dev/null @@ -1,38 +0,0 @@ -{-# LANGUAGE CPP #-} - - -import System.Environment -import System.FilePath - -import Test.Haddock -import Test.Haddock.Xhtml - - -checkConfig :: CheckConfig Xhtml -checkConfig = CheckConfig - { ccfgRead = \mdl input -> stripIfRequired mdl <$> parseXhtml input - , ccfgDump = dumpXhtml - , ccfgEqual = (==) - } - - -dirConfig :: DirConfig -dirConfig = defaultDirConfig $ takeDirectory __FILE__ - - -main :: IO () -main = runAndCheck =<< parseArgs checkConfig dirConfig =<< getArgs - - -stripIfRequired :: String -> Xhtml -> Xhtml -stripIfRequired mdl = - stripLinks' . stripFooter - where - stripLinks' - | mdl `elem` preserveLinksModules = id - | otherwise = stripLinks - - --- | List of modules in which we don't 'stripLinks' -preserveLinksModules :: [String] -preserveLinksModules = ["Bug253"] -- cgit v1.2.3