shadower (empty) → 0.1.0.2
raw patch · 4 files changed
+94/−0 lines, 4 filesdep +MissingHdep +basedep +doctestsetup-changed
Dependencies added: MissingH, base, doctest, filemanip, fsnotify, process, system-filepath, text
Files
- LICENSE +24/−0
- Setup.hs +2/−0
- shadower.cabal +18/−0
- src/Shadower.hs +50/−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
+ shadower.cabal view
@@ -0,0 +1,18 @@+name: shadower+version: 0.1.0.2+synopsis: An automated way to run doctests in files that are changing+description: Shadower watches folders with Haskell sources, and runs doctests in files that are modified+homepage: http://github.com/karun012/shadower+license: PublicDomain+license-file: LICENSE+author: Karun Ramakrishnan+maintainer: karun012@gmail.com+category: Testing+build-type: Simple+cabal-version: >=1.10++executable shadower+ default-language: Haskell2010+ build-depends: base >4 && <5, fsnotify, process, system-filepath, text, filemanip, MissingH, doctest+ main-is: Shadower.hs + HS-Source-Dirs: src
+ src/Shadower.hs view
@@ -0,0 +1,50 @@+{-# OPTIONS -Wall #-}+ +module Main where++import Filesystem.Path.CurrentOS (fromText, encodeString)+import Data.Text (pack)+import Data.String.Utils++import Control.Exception+import qualified Control.Exception as E++import System.FSNotify+import System.Environment+import System.Exit++import Test.DocTest++main :: IO ()+main = getArgs >>= getFilePathFromArgs >>= watchPath++getFilePathFromArgs :: [String] -> IO FilePath+getFilePathFromArgs (filePath:_) = return filePath+getFilePathFromArgs [] = return "."++watchPath :: FilePath -> IO ()+watchPath path = withManager $ \manager -> do+ _ <- watchTree manager (fromText $ pack path) (const True) handler+ _ <- getLine+ exitSuccess++handler :: Event -> IO()+handler action = case action of + Modified file _ -> maybeRunDocTests (encodeString file)+ _ -> return ()++maybeRunDocTests :: String -> IO ()+maybeRunDocTests file = case isHaskellSource file of + True -> E.catch (runDocTests file) ignoreAllExceptions+ _ -> return ()++ignoreAllExceptions :: SomeException -> IO ()+ignoreAllExceptions _ = return ()++runDocTests :: String -> IO ()+runDocTests file = do+ _ <- putStrLn $ "Running doctests in " ++ file+ doctest [file]++isHaskellSource :: String -> Bool+isHaskellSource file = endswith ".hs" file || endswith ".lhs" file