doctest-discover 0.1.0.7 → 0.1.0.8
raw patch · 3 files changed
+26/−18 lines, 3 files
Files
- doctest-discover.cabal +1/−1
- src/Main.hs +16/−8
- src/Runner.hs +9/−9
doctest-discover.cabal view
@@ -1,5 +1,5 @@ name: doctest-discover-version: 0.1.0.7+version: 0.1.0.8 synopsis: Easy way to run doctests via cabal description: doctest-discover provides an easy way to run doctests via cabal license: PublicDomain
src/Main.hs view
@@ -23,12 +23,20 @@ let testDriverFileContents = driver (concat files) customConfiguration writeFile dst testDriverFileContents +-- | Recursively get absolute directory contents+--+-- >>> :m +Data.List+-- >>> prefix <- getCurrentDirectory+-- >>> map (stripPrefix prefix) <$> getAbsDirectoryContents "test/example"+-- [Just "/test/example/Foo.hs",Just "/test/example/Foo/Bar.hs"]+-- getAbsDirectoryContents :: FilePath -> IO [FilePath]-getAbsDirectoryContents dir = getDirectoryContents dir >>= mapM (canonicalizePath . (dir </>))-------+getAbsDirectoryContents dir = do+ paths <- getDirectoryContents dir+ paths' <- forM (filter (`notElem` [".", ".."]) paths) $ \path -> do+ canonicalized <- canonicalizePath $ dir </> path+ isDir <- doesDirectoryExist canonicalized+ if isDir+ then getAbsDirectoryContents canonicalized+ else return [canonicalized]+ return $ concat paths'
src/Runner.hs view
@@ -8,7 +8,7 @@ -- | Generates doctest driver ----- >>> let expected = unlines ["module Main where", "import Test.DocTest", "main :: IO ()", "main = doctest [\"-i/src\",\"foo.hs\",\"bar.hs\"]"]+-- >>> let expected = unlines ["module Main where", "import Test.DocTest", "main :: IO ()", "main = doctest [\"-isrc\",\"foo.hs\",\"bar.hs\"]"] -- >>> let actual = driver ["foo.hs", "bar.hs", "baz.qux"] Nothing -- >>> expected == actual -- True@@ -19,25 +19,25 @@ -- | Generates doctest configuration -- -- >>> generateConfig ["foo.hs", "bar.hs", "baz.qux"] Nothing--- ["-i/src","foo.hs","bar.hs"]+-- ["-isrc","foo.hs","bar.hs"] -- -- >>> let config = Just (Config (Just ["bar.hs"]) Nothing) -- >>> generateConfig ["foo.hs", "bar.hs", "baz.qux"] config--- ["-i/src","foo.hs"]+-- ["-isrc","foo.hs"] -- -- >>> let config = Just (Config Nothing (Just ["qux"])) -- >>> generateConfig ["foo.hs", "bar.hs", "baz.qux"] config--- ["-i/qux","foo.hs","bar.hs"]+-- ["-iqux","foo.hs","bar.hs"] -- -- >>> let config = Just (Config (Just ["bar.hs"]) (Just ["qux"])) -- >>> generateConfig ["foo.hs", "bar.hs", "baz.qux"] config--- ["-i/qux","foo.hs"]+-- ["-iqux","foo.hs"] -- generateConfig :: [FilePath] -> Maybe Config -> [String]-generateConfig files (Just (Config Nothing (Just sourceFolders))) = ((++) (map ("-i/"++) sourceFolders) . notCurrentAndParent . filterHaskellSources) files-generateConfig files (Just (Config (Just ignoreList) Nothing)) = ((:) "-i/src" . filter (`notElem` ignoreList) . notCurrentAndParent . filterHaskellSources) files-generateConfig files (Just (Config (Just ignoreList) (Just sourceFolders))) = ((++) (map ("-i/"++) sourceFolders) . filter (`notElem` ignoreList) . notCurrentAndParent . filterHaskellSources) files-generateConfig files _ = ((:) "-i/src" . notCurrentAndParent . filterHaskellSources) files+generateConfig files (Just (Config Nothing (Just sourceFolders))) = ((++) (map ("-i"++) sourceFolders) . notCurrentAndParent . filterHaskellSources) files+generateConfig files (Just (Config (Just ignoreList) Nothing)) = ((:) "-isrc" . filter (`notElem` ignoreList) . notCurrentAndParent . filterHaskellSources) files+generateConfig files (Just (Config (Just ignoreList) (Just sourceFolders))) = ((++) (map ("-i"++) sourceFolders) . filter (`notElem` ignoreList) . notCurrentAndParent . filterHaskellSources) files+generateConfig files _ = ((:) "-isrc" . notCurrentAndParent . filterHaskellSources) files -- | Filters out current and parent directories --