aboutsummaryrefslogtreecommitdiff
path: root/html-test/run.hs
blob: 99ca1ec170e97f294b7fb8ad5febf9e6534f1295 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env runhaskell
{-# LANGUAGE CPP #-}


import System.Directory
import System.Environment
import System.FilePath


baseDir, rootDir :: FilePath
baseDir = takeDirectory __FILE__
rootDir = baseDir </> ".."

srcDir, refDir, outDir :: FilePath
srcDir = baseDir </> "src"
refDir = baseDir </> "ref"
outDir = baseDir </> "out"


main :: IO ()
main = do
    files <- processArgs =<< getArgs
    putStrLn $ "Files to test: " ++ show files


processArgs :: [String] -> IO [FilePath]
processArgs [] = filter isSourceFile <$> getDirectoryContents srcDir
processArgs args = pure $ map processArg args


processArg :: String -> FilePath
processArg arg
    | isSourceFile arg = arg
    | otherwise = srcDir </> arg <.> "hs"


isSourceFile :: FilePath -> Bool
isSourceFile path = takeExtension path `elem` [".hs", ".lhs"]