stack-hpc-coveralls 0.0.0.1 → 0.0.0.2
raw patch · 6 files changed
+34/−72 lines, 6 filesdep ~hspec
Dependency ranges changed: hspec
Files
- app/Main.hs +5/−5
- src/SHC.hs +3/−4
- src/SHC/Coveralls.hs +4/−3
- src/SHC/Paths.hs +0/−56
- src/SHC/Utils.hs +20/−1
- stack-hpc-coveralls.cabal +2/−3
app/Main.hs view
@@ -44,16 +44,16 @@ getConfig :: Arguments -> IO Config getConfig args = do -- TODO: Read from Cabal?- pn <- args `getArgOrExit` (argument "package-name")+ pn <- args `getArgOrExit` argument "package-name" (sn, jId) <- getServiceAndJobId- Config <$> args `getArgOrExit` (argument "suite-name")+ Config <$> args `getArgOrExit` argument "suite-name" <*> pure sn <*> pure jId- <*> pure (args `getArg` (longOption "repo-token"))+ <*> pure (args `getArg` longOption "repo-token") <*> getGitInfo <*> defaultOr args (longOption "hpc-dir") (getHpcDir pn) <*> defaultOr args (longOption "hpc-dir") getMixDir- <*> pure (if args `isPresent` (longOption "partial-coverage")+ <*> pure (if args `isPresent` longOption "partial-coverage" then PartialLines else FullLines) @@ -62,7 +62,7 @@ args <- parseArgsOrExit patterns =<< getArgs conf <- getConfig args coverallsJson <- generateCoverallsFromTix conf- if args `isPresent` (longOption "dont-send")+ if args `isPresent` longOption "dont-send" then BSL.putStr $ encode coverallsJson else do response <- sendData conf urlApiV1 coverallsJson
src/SHC.hs view
@@ -1,5 +1,5 @@-module SHC (- Config(..)+module SHC+ ( Config(..) , ConversionType(..) , PostResult(..) , generateCoverallsFromTix@@ -8,8 +8,7 @@ , getHpcDir , getMixDir , getGitInfo- )- where+ ) where import SHC.Types
src/SHC/Coveralls.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} -- |@@ -20,11 +21,11 @@ import Data.Function import Data.List import qualified Data.Map.Strict as M+import System.FilePath ((</>)) import System.Exit (exitFailure) import SHC.Types import SHC.Utils import SHC.Lix-import SHC.Paths import Trace.Hpc.Mix import Trace.Hpc.Tix import Trace.Hpc.Util@@ -44,7 +45,7 @@ type LixConverter = Lix -> SimpleCoverage strictConverter :: LixConverter-strictConverter = map $ \lix -> case lix of+strictConverter = map $ \case Full -> Number 1 Partial -> Number 0 None -> Number 0@@ -106,7 +107,7 @@ -- | Create a list of coverage data from the tix input readCoverageData :: Config -> String -> IO TestSuiteCoverageData readCoverageData conf suite = do- let tixPath = getTixPath (hpcDir conf) suite+ let tixPath = hpcDir conf </> "tix" </> suite </> getTixFileName suite mTix <- readTix tixPath case mTix of Nothing -> putStrLn ("Couldn't find the file " ++ tixPath) >>
− src/SHC/Paths.hs
@@ -1,56 +0,0 @@--- |--- Module: Trace.Hpc.Coveralls.Paths--- Copyright: (c) 2014-2015 Guillaume Nargeot--- License: BSD3--- Maintainer: Guillaume Nargeot <guillaume+hackage@nargeot.com>--- Stability: experimental------ Paths constants and functions for hpc coverage report output.--module SHC.Paths- where--import Control.Monad-import Data.Maybe-import Data.List (isSuffixOf)-import Data.Traversable (traverse)-import System.Directory (- doesDirectoryExist, getDirectoryContents- )-import System.Directory.Tree (- AnchoredDirTree(..), dirTree, readDirectoryWith- )-import System.FilePath ((</>))-import Trace.Hpc.Tix---tixDir :: FilePath -> FilePath-tixDir = (</> "tix")--mixDir :: FilePath -> FilePath-mixDir = (</> "mix")--getTixPath :: FilePath -> String -> FilePath-getTixPath hpcDir testSuiteName = tixDir hpcDir </> testSuiteName </> getTixFileName testSuiteName--firstExistingDirectory :: [FilePath] -> IO (Maybe FilePath)-firstExistingDirectory = fmap msum . mapM pathIfExist- where pathIfExist path = do- pathExists <- doesDirectoryExist path- return $ if pathExists then Just path else Nothing--dumpDirectory :: FilePath -> IO ()-dumpDirectory path = do- directoryExists <- doesDirectoryExist path- unless directoryExists $ putStrLn ("Couldn't find the directory " ++ path)- putStrLn $ "Dumping " ++ path ++ " directory content:"- contents <- getDirectoryContents path- traverse putStrLn contents- return ()--dumpDirectoryTree :: FilePath -> IO ()-dumpDirectoryTree path = do- putStrLn $ "Dumping " ++ path ++ " directory tree:"- tree <- readDirectoryWith return path- traverse putStrLn $ dirTree tree- return ()
src/SHC/Utils.hs view
@@ -3,10 +3,13 @@ import Data.List import Data.Function (on)-import Control.Monad (guard)+import Data.Traversable (traverse)+import Control.Monad (guard, unless) import Control.Applicative ((<$>), (<*>)) import System.Process (readProcess) import System.FilePath ((</>))+import System.Directory (doesDirectoryExist, getDirectoryContents)+import System.Directory.Tree (AnchoredDirTree(..), dirTree, readDirectoryWith) import SHC.Types @@ -45,6 +48,22 @@ getMixDir :: IO FilePath getMixDir = (</> "hpc") <$> stack ["path", "--dist-dir"]++dumpDirectory :: FilePath -> IO ()+dumpDirectory path = do+ directoryExists <- doesDirectoryExist path+ unless directoryExists $ putStrLn ("Couldn't find the directory " ++ path)+ putStrLn $ "Dumping " ++ path ++ " directory content:"+ contents <- getDirectoryContents path+ traverse putStrLn contents+ return ()++dumpDirectoryTree :: FilePath -> IO ()+dumpDirectoryTree path = do+ putStrLn $ "Dumping " ++ path ++ " directory tree:"+ tree <- readDirectoryWith return path+ traverse putStrLn $ dirTree tree+ return () fst3 :: (a, b, c) -> a fst3 (x, _, _) = x
stack-hpc-coveralls.cabal view
@@ -1,5 +1,5 @@ name: stack-hpc-coveralls-version: 0.0.0.1+version: 0.0.0.2 synopsis: Initial project template from stack description: Please see README.md homepage: http://github.com/rubik/stack-hpc-coveralls@@ -19,7 +19,6 @@ exposed-modules: SHC other-modules: SHC.Coveralls SHC.Types- SHC.Paths SHC.Utils SHC.Lix SHC.Api@@ -59,7 +58,7 @@ main-is: Spec.hs build-depends: base >=4.7 && <5 , stack-hpc-coveralls -any- , hspec >=2.2+ , hspec >=2.1 ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N default-language: Haskell2010