diff options
-rw-r--r-- | haddock.cabal | 4 | ||||
-rw-r--r-- | html-test/README | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | html-test/accept.lhs (renamed from html-test/accept.hs) | 15 | ||||
-rwxr-xr-x[-rw-r--r--] | html-test/runtests.lhs (renamed from html-test/runtests.hs) | 16 |
4 files changed, 24 insertions, 15 deletions
diff --git a/haddock.cabal b/haddock.cabal index 8f655d83..67e86452 100644 --- a/haddock.cabal +++ b/haddock.cabal @@ -31,7 +31,7 @@ extra-source-files: src/haddock.sh -- The test files shouldn't have to go here, but the source files for -- the test-suite stanzas don't get picked up by `cabal sdist`. - tests/html-test/runtests.hs + tests/html-test/runtests.lhs data-dir: resources data-files: html/frames.html @@ -172,7 +172,7 @@ library test-suite html-test type: exitcode-stdio-1.0 default-language: Haskell2010 - main-is: runtests.hs + main-is: runtests.lhs hs-source-dirs: html-test build-depends: base, directory, process, filepath, Cabal diff --git a/html-test/README b/html-test/README index 9afb10e7..d261888c 100644 --- a/html-test/README +++ b/html-test/README @@ -9,12 +9,12 @@ To add a new test: passes since there is no reference file to compare with. 3) To make a reference file from the output file, do - runhaskell accept.hs <modulename> + runhaskell accept.lhs <modulename> Tips and tricks: To "accept" all output files (copy them to reference files), run - runhaskell accept.hs + runhaskell accept.lhs You can run all tests despite failing tests, like so cabal test --test-option=all diff --git a/html-test/accept.hs b/html-test/accept.lhs index 4722dbf9..3dfc099b 100644..100755 --- a/html-test/accept.hs +++ b/html-test/accept.lhs @@ -1,3 +1,6 @@ +#!/usr/bin/env runhaskell +\begin{code} +{-# LANGUAGE CPP #-} import System.Cmd import System.Environment import System.FilePath @@ -5,15 +8,16 @@ import System.Directory import Data.List import Control.Applicative +baseDir = takeDirectory __FILE__ + main :: IO () main = do + contents <- filter (`notElem` ignore) <$> getDirectoryContents (baseDir </> "output") args <- getArgs - dir <- getCurrentDirectory - contents <- filter (`notElem` ignore) <$> getDirectoryContents (dir </> "output") if not $ null args then - mapM_ copy [ "output" </> file | file <- contents, ".html" `isSuffixOf` file, takeBaseName file `elem` args ] + mapM_ copy [ baseDir </> "output" </> file | file <- contents, ".html" `isSuffixOf` file, takeBaseName file `elem` args ] else - mapM_ copy [ "output" </> file | file <- contents] + mapM_ copy [ baseDir </> "output" </> file | file <- contents] where ignore = [ "." @@ -25,7 +29,7 @@ main = do copy :: FilePath -> IO () copy file = do - let new = "ref" </> takeFileName file + let new = baseDir </> "ref" </> takeFileName file if ".html" `isSuffixOf` file then do putStrLn (file ++ " -> " ++ new) stripLinks <$> readFile file >>= writeFile new @@ -42,3 +46,4 @@ stripLinks str = case str of [] -> [] x : xs -> x : stripLinks xs +\end{code} diff --git a/html-test/runtests.hs b/html-test/runtests.lhs index 1898cde3..c8671a76 100644..100755 --- a/html-test/runtests.hs +++ b/html-test/runtests.lhs @@ -1,3 +1,6 @@ +#!/usr/bin/env runhaskell +\begin{code} +{-# LANGUAGE CPP #-} import Prelude hiding (mod) import Control.Monad import Control.Applicative @@ -20,14 +23,14 @@ import System.FilePath import System.Process (ProcessHandle, runProcess, waitForProcess) -packageRoot, dataDir, haddockPath, testSuiteRoot, testDir, outDir :: FilePath -packageRoot = "." +packageRoot, dataDir, haddockPath, baseDir, testDir, outDir :: FilePath +baseDir = takeDirectory __FILE__ +testDir = baseDir </> "tests" +refDir = baseDir </> "ref" +outDir = baseDir </> "output" +packageRoot = baseDir </> ".." dataDir = packageRoot </> "resources" haddockPath = packageRoot </> "dist" </> "build" </> "haddock" </> "haddock" -testSuiteRoot = packageRoot </> "html-test" -testDir = testSuiteRoot </> "tests" -refDir = testSuiteRoot </> "ref" -outDir = testSuiteRoot </> "output" main :: IO () @@ -150,3 +153,4 @@ programOnPath :: FilePath -> IO Bool programOnPath p = do result <- findProgramLocation silent p return (isJust result) +\end{code} |