diff options
author | Mateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk> | 2013-08-27 05:03:43 +0100 |
---|---|---|
committer | Simon Hengel <sol@typeful.net> | 2013-08-27 21:22:48 +0200 |
commit | 355087a58416683f16d65457577ef4b575b55a64 (patch) | |
tree | 716ea2217ea2c3ee337976749444c7d3370c90cc /latex-test/accept.lhs | |
parent | ac04da29b1a2bfb7139b7e9d0d2b88ea397a3bcc (diff) |
LaTeX tests setup
Diffstat (limited to 'latex-test/accept.lhs')
-rwxr-xr-x | latex-test/accept.lhs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/latex-test/accept.lhs b/latex-test/accept.lhs new file mode 100755 index 00000000..4d0b0127 --- /dev/null +++ b/latex-test/accept.lhs @@ -0,0 +1,46 @@ +#!/usr/bin/env runhaskell +\begin{code} +{-# LANGUAGE CPP #-} +import System.Environment +import System.FilePath +import System.Directory +import Data.List +import Control.Applicative +import Control.Monad + +baseDir :: FilePath +baseDir = takeDirectory __FILE__ + +main :: IO () +main = do + contents <- filter (not . ignore) <$> getDirectoryContents (baseDir </> "out") + args <- getArgs + mapM_ copyDir $ if not (null args) + then filter ((`elem` args) . takeBaseName) contents + else contents + where + ignore = + foldr (liftA2 (||)) (const False) [ + (== ".") + , (== "..") + , isPrefixOf "index" + , isPrefixOf "doc-index" + ] + +-- | Copy a directory to ref, one level deep. +copyDir :: FilePath -> IO () +copyDir dir = do + let old = baseDir </> "out" </> dir + new = baseDir </> "ref" </> dir + alreadyExists <- doesDirectoryExist new + unless alreadyExists $ do + putStrLn (old ++ " -> " ++ new) + createDirectoryIfMissing True new + files <- getDirectoryContents old >>= filterM (liftM not . doesDirectoryExist) + let files' = filter (\x -> x /= "." && x /= "..") files + mapM_ (\f -> copyFile' (old </> f) (new </> f)) files' + where + copyFile' o n = do + putStrLn $ o ++ " -> " ++ n + copyFile o n +\end{code} |