testloop 0.1.0.2 → 0.1.1.0
raw patch · 3 files changed
+51/−13 lines, 3 filesdep ~filepathdep ~hintdep ~mtl
Dependency ranges changed: filepath, hint, mtl, time, unix
Files
- src/System/TestLoop.hs +24/−3
- src/System/TestLoop/Internal/Watcher.hs +25/−8
- testloop.cabal +2/−2
src/System/TestLoop.hs view
@@ -75,12 +75,33 @@ -------------------------------------------------------------------------------- -- | Parses your project's cabal file to find possible test-suites you--- may have on your project, then it will start a file modification--- tracking and once a file is changed it will run the testsuite--- automatically. in the test-suite's hs-source-dirs setting.+-- may have on your project, then it will start a tracking process+-- that listens to changes on files specified on the hs-source-dirs+-- parameter of your testsuite, once a file is changed this process will+-- run the testsuite automatically. -- -- Use this function as the main of you testloop executable. -- e.g+--+-- On Cabal File+--+-- > test-suite lib-tests+-- > type: exitcode-stdio-1.0+-- > main-is: TestSuite.hs+-- > hs-source-dirs:+-- > src, test+-- > build-depends:+-- > -- test dependencies+-- >+-- > executable testloop+-- > main-is: TestLoop.hs+-- > hs-source-dirs:+-- > src, test+-- > build-depends:+-- > -- Your lib/app and test dependencies ... + testloop+-- > testloop+--+-- On test/TestLoop.hs -- -- > module Main where -- >
src/System/TestLoop/Internal/Watcher.hs view
@@ -2,10 +2,11 @@ -------------------- +import Control.Monad (liftM, sequence) import Control.Monad.Trans (MonadIO (..)) import Data.List (intercalate, isPrefixOf,- nub)-import Data.Monoid (mconcat)+ isSuffixOf, nub)+import Data.Monoid (mconcat, First(..)) import qualified Filesystem.Path as FS import qualified Filesystem.Path.CurrentOS as FS @@ -36,18 +37,34 @@ -------------------------------------------------------------------------------- -getPackageDatabaseFile :: IO (Maybe FilePath)-getPackageDatabaseFile = do- cabalDevExists <- doesDirectoryExist "cabal-dev"++_getPackageDatabaseFile :: FilePath+ -> (FilePath -> Bool)+ -> IO (Maybe FilePath)+_getPackageDatabaseFile folderName isPackageDatabase = do+ cabalDevExists <- doesDirectoryExist folderName if (not cabalDevExists) then return Nothing else do dir <- getCurrentDirectory- let cabalDevDir = joinPath [dir, "cabal-dev"]+ let cabalDevDir = joinPath [dir, folderName] packages <- getDirectoryContents cabalDevDir- case filter ("packages-" `isPrefixOf`) packages of+ case filter isPackageDatabase packages of (packagesFile:_) -> return $ Just (joinPath [cabalDevDir, packagesFile])- _ -> return Nothing++getCabalDevPackageDatabaseFile :: IO (Maybe FilePath)+getCabalDevPackageDatabaseFile =+ _getPackageDatabaseFile "cabal-dev" ("packages-" `isPrefixOf`)++getCabalSandboxPackageDatabaseFile :: IO (Maybe FilePath)+getCabalSandboxPackageDatabaseFile =+ _getPackageDatabaseFile ".cabal-sandbox" ("packages.conf.d" `isSuffixOf`)++getPackageDatabaseFile :: IO (Maybe FilePath)+getPackageDatabaseFile =+ liftM (getFirst . mconcat . map First) $+ sequence [ getCabalSandboxPackageDatabaseFile+ , getCabalDevPackageDatabaseFile ] reloadTestSuite :: MainModuleName
testloop.cabal view
@@ -10,7 +10,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.1.0.2+version: 0.1.1.0 -- A short (one-line) description of the package. synopsis: Quick feedback loop for test suites@@ -21,7 +21,7 @@ your project's test-suites whenever a haskell source file is modified. - To get started check out http://github.com/roman/testloop+ To get started check out <http://github.com/roman/testloop> -- URL for the project homepage or repository. homepage: http://github.com/roman/testloop