doctest-discover (empty) → 0.1.0.0
raw patch · 6 files changed
+127/−0 lines, 6 filesdep +basedep +directorydep +doctestsetup-changed
Dependencies added: base, directory, doctest, filepath, temporary
Files
- LICENSE +24/−0
- Setup.hs +2/−0
- doctest-discover.cabal +29/−0
- src/Main.hs +25/−0
- src/Runner.hs +46/−0
- test/Doctest-Main.hs +1/−0
+ LICENSE view
@@ -0,0 +1,24 @@+This is free and unencumbered software released into the public domain.++Anyone is free to copy, modify, publish, use, compile, sell, or+distribute this software, either in source code form or as a compiled+binary, for any purpose, commercial or non-commercial, and by any+means.++In jurisdictions that recognize copyright laws, the author or authors+of this software dedicate any and all copyright interest in the+software to the public domain. We make this dedication for the benefit+of the public at large and to the detriment of our heirs and+successors. We intend this dedication to be an overt act of+relinquishment in perpetuity of all present and future rights to this+software under copyright law.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR+OTHER DEALINGS IN THE SOFTWARE.++For more information, please refer to <http://unlicense.org/>
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ doctest-discover.cabal view
@@ -0,0 +1,29 @@+-- Initial doctest-discover.cabal generated by cabal init. For further +-- documentation, see http://haskell.org/cabal/users-guide/++name: doctest-discover+version: 0.1.0.0+synopsis: Easy way to run doctests via cabal+description: doctest-discover makes it easy to run doctests via cabal+license: PublicDomain+license-file: LICENSE+author: Karun Ramakrishnan+maintainer: karun012@gmail.com+category: Testing+build-type: Simple+cabal-version: >=1.10++executable doctest-discover+ default-language: Haskell2010+ build-depends: base >=4.6 && <4.7, doctest, directory, filepath, temporary+ main-is: Main.hs + other-modules: Runner+ HS-Source-Dirs: src++test-suite doctests+ default-language: Haskell2010+ type: exitcode-stdio-1.0+ ghc-options: -threaded+ main-is: Doctest-Main.hs+ build-depends: base >4 && <5, doctest+ HS-Source-Dirs: test
+ src/Main.hs view
@@ -0,0 +1,25 @@+module Main where++import System.Environment+import Runner+import System.Directory+++main :: IO ()+main = do+ (src : _ : dst : args) <- getArgs+ files <- getDirectoryContents "src" + let config = generateConfig files + writeFile dst (makeFileContents config)++makeFileContents :: [String] -> String+makeFileContents config = unlines [+ "module Main where",+ "import Test.DocTest",+ "main :: IO ()",+ "main = doctest " ++ show config+ ]++++
+ src/Runner.hs view
@@ -0,0 +1,46 @@+module Runner (+ generateConfig+) where++import Test.DocTest+import System.Directory+import Data.List+import System.FilePath.Posix++-- | Generates doctest configuration+--+-- >>> generateConfig ["foo.hs", "bar.hs", "baz.qux"]+-- ["-isrc","foo","bar"]+--+generateConfig :: [FilePath] -> [String]+generateConfig = ((:) "-isrc" . dropFileExtensions . notCurrentAndParent . filterHaskellSources) ++-- | Drops file extensions+-- +-- >>> dropFileExtensions ["foo.bar", "bar.baz", "baz.qux"]+-- ["foo","bar","baz"]++dropFileExtensions :: [FilePath] -> [String]+dropFileExtensions = map dropExtension++-- | Filters out current and parent directories +--+-- >>> notCurrentAndParent ["wat", ".", "..", "wat"]+-- ["wat","wat"]++notCurrentAndParent :: [FilePath] -> [FilePath]+notCurrentAndParent = filter (`notElem` [".", ".."])++-- | Filters out haskell source files+--+-- >>> filterHaskellSources []+-- []+--+-- >>> filterHaskellSources ["foo.hs", "bar.lhs", "foo.txt", "baz.qux"]+-- ["foo.hs","bar.lhs"]+--+filterHaskellSources :: [FilePath] -> [FilePath]+filterHaskellSources = filter isHaskellSource++isHaskellSource :: FilePath -> Bool+isHaskellSource file = isSuffixOf ".hs" file || isSuffixOf ".lhs" file
+ test/Doctest-Main.hs view
@@ -0,0 +1,1 @@+{-# OPTIONS_GHC -F -pgmF doctest-discover #-}