hpc-coveralls 0.2.1 → 0.2.2
raw patch · 6 files changed
+53/−31 lines, 6 filesdep +asyncdep +hpc-coverallsdep ~bytestringdep ~curldep ~hpcPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: async, hpc-coveralls
Dependency ranges changed: bytestring, curl, hpc
API changes (from Hackage documentation)
- HpcCoverallsCmdLine: CmdMain :: Maybe [String] -> [String] -> Bool -> HpcCoverallsArgs
+ HpcCoverallsCmdLine: CmdMain :: [String] -> [String] -> Bool -> HpcCoverallsArgs
- HpcCoverallsCmdLine: excludeDirs :: HpcCoverallsArgs -> Maybe [String]
+ HpcCoverallsCmdLine: excludeDirs :: HpcCoverallsArgs -> [String]
Files
- CHANGELOG.md +5/−0
- README.md +20/−4
- hpc-coveralls.cabal +7/−10
- src/HpcCoverallsCmdLine.hs +4/−4
- src/HpcCoverallsMain.hs +2/−4
- src/RunCabalTestMain.hs +15/−9
CHANGELOG.md view
@@ -1,3 +1,8 @@+[0.2.2](https://github.com/guillaume-nargeot/hpc-coveralls/issues?milestone=3&state=closed)+* Prevent double compilation (issue #11)+* Concurrently process cabal test stdout and stderr channels (issue #12)+* Test with GHC 7.8.2+ [0.2.1](https://github.com/guillaume-nargeot/hpc-coveralls/issues?milestone=2&state=closed) ----- * Additional CI services support (issue #1)
README.md view
@@ -11,21 +11,31 @@ ## Travis CI -Commands to add to your project `.travis.yml`:+Commands to add to your project `.travis.yml` when using GHC 7.8: ```yaml before_install: - cabal install hpc-coveralls script:+ - cabal configure --enable-tests --enable-library-coverage && cabal build && cabal test+after_script:+ - hpc-coveralls [options] [test-suite-name]+```++When using a GHC version prior to 7.8, you have to replace the `cabal test` command by `run-cabal-test`, as in the following example:+```yaml+before_install:+ - cabal install hpc-coveralls+script: - cabal configure --enable-tests --enable-library-coverage && cabal build - run-cabal-test [options] [cabal-test-options] after_script: - hpc-coveralls [options] [test-suite-name] ``` -Note that the usual `cabal test` command is replaced by `run-cabal-test`. The reason for this is explained in the next section. -For an example usage, please refer to [this-project](https://github.com/guillaume-nargeot/project-euler-haskell) `.travis.yml` file ([result on coveralls](https://coveralls.io/r/guillaume-nargeot/project-euler-haskell)).+For a real world example usage, please refer to [this-project](https://github.com/guillaume-nargeot/project-euler-haskell) `.travis.yml` file ([result on coveralls](https://coveralls.io/r/guillaume-nargeot/project-euler-haskell)).+You can also refer to the `.travis.yml` file of hpc-coveralls itself, which is configured with [multi-ghc-travis](https://github.com/hvr/multi-ghc-travis). ## The run-cabal-test command @@ -33,7 +43,7 @@ In order to prevent this from happening, hpc-coveralls provides the `run-cabal-test` command which runs `cabal test` and returns with `0` if the regex `^Test suite .*: FAIL$` never matches any line of the output. -This hpc issue should be fixed in version 0.7 (not yet available on Travis CI).+As this issue is fixed in the hpc version shipped with GHC 7.8, you don't have to use `run-cabal-test` when testing with GHC 7.8 and can safely use `cabal test`. ### Options @@ -59,6 +69,12 @@ ```yaml hpc-coveralls --exclude-dir=test [test-suite-name]+```++You can specify multiple excluded folders by using the following example syntax:++```yaml+hpc-coveralls --exclude-dir=test1 --exclude-dir=test2 [test-suite-name] ``` # Limitations
hpc-coveralls.cabal view
@@ -1,5 +1,5 @@ name: hpc-coveralls-version: 0.2.1+version: 0.2.2 synopsis: Coveralls.io support for Haskell. description: This utility converts and sends Haskell projects hpc code coverage to@@ -12,8 +12,7 @@ > before_install: > - cabal install hpc-coveralls > script:- > - cabal configure --enable-tests --enable-library-coverage && cabal build- > - run-cabal-test [options] [cabal-test-options]+ > - cabal configure --enable-tests --enable-library-coverage && cabal build && cabal test > after_script: > - hpc-coveralls [options] [test-suite-name] .@@ -28,7 +27,7 @@ build-type: Simple stability: experimental cabal-version: >= 1.8-tested-with: GHC == 7.6.3+tested-with: GHC == 7.6, GHC == 7.8 bug-reports: https://github.com/guillaume-nargeot/hpc-coveralls homepage: https://github.com/guillaume-nargeot/hpc-coveralls/issues @@ -41,7 +40,7 @@ location: https://github.com/guillaume-nargeot/hpc-coveralls.git library- hs-source-dirs: src+ hs-source-dirs: src exposed-modules: HpcCoverallsCmdLine, Trace.Hpc.Coveralls,@@ -74,6 +73,7 @@ hs-source-dirs: src main-is: RunCabalTestMain.hs build-depends:+ async >= 2.0.0.0, base < 5, process, regex-posix,@@ -81,14 +81,11 @@ ghc-options: -Wall -fwarn-tabs test-suite test-all- hs-source-dirs: src, test+ hs-source-dirs: test type: exitcode-stdio-1.0 main-is: TestAll.hs build-depends:- aeson, base,- bytestring,- curl,- hpc,+ hpc-coveralls, HUnit ghc-options: -Wall
src/HpcCoverallsCmdLine.hs view
@@ -8,16 +8,16 @@ import System.Console.CmdArgs data HpcCoverallsArgs = CmdMain- { excludeDirs :: Maybe [String]+ { excludeDirs :: [String] , testSuites :: [String] , displayReport :: Bool } deriving (Data, Show, Typeable) hpcCoverallsArgs :: HpcCoverallsArgs hpcCoverallsArgs = CmdMain- { excludeDirs = Nothing &= explicit &= typDir &= name "exclude-dir" &= help "Exclude sources files under the matching directory from the coverage report send to coveralls.io"- , displayReport = False &= explicit &= name "display-report" &= help "Display the json code coverage report that will be sent to coveralls.io"- , testSuites = [] &= typ "TEST-SUITE" &= args+ { excludeDirs = [] &= explicit &= typDir &= name "exclude-dir" &= help "Exclude sources files under the matching directory from the coverage report send to coveralls.io"+ , displayReport = False &= explicit &= name "display-report" &= help "Display the json code coverage report that will be sent to coveralls.io"+ , testSuites = [] &= typ "TEST-SUITE" &= args } &= summary ("hpc-coveralls-" ++ versionString version ++ ", (C) Guillaume Nargeot 2014") &= program "hpc-coveralls" where versionString = intercalate "." . map show . versionBranch
src/HpcCoverallsMain.hs view
@@ -36,10 +36,8 @@ toConfig :: HpcCoverallsArgs -> Maybe Config toConfig hca = case testSuites hca of- [testSuite] -> case excludeDirs hca of- Nothing -> Just $ Config [testSuite] []- Just dirs -> Just $ Config [testSuite] dirs- _ -> Nothing+ [testSuite] -> Just $ Config [testSuite] (excludeDirs hca)+ _ -> Nothing main :: IO () main = do
src/RunCabalTestMain.hs view
@@ -1,9 +1,11 @@ module Main where +import Control.Concurrent.Async (Async, async, waitBoth) import Control.Monad import Data.List import Data.List.Split import GHC.IO.Handle+import System.IO (hPutStrLn, stdout, stderr) import System.Exit (exitFailure, exitSuccess) import System.Environment (getArgs) import System.Process@@ -15,23 +17,27 @@ isTestFailure :: String -> Bool isTestFailure line = line =~ "^Test suite .*: FAIL$" -readLines :: Handle -> IO [String]-readLines h = do- isEOF <- hIsEOF h+readLines :: Handle -> Handle -> IO [String]+readLines hIn hOut = do+ isEOF <- hIsEOF hIn if isEOF then return [] else do- x <- hGetLine h- putStrLn x- xs <- readLines h+ x <- hGetLine hIn+ hPutStrLn hOut x+ xs <- readLines hIn hOut return (x : xs) +checkFailure :: Handle -> Handle -> IO (Async Bool)+checkFailure hIn = async . liftM (not . any isTestFailure) . readLines hIn+ runCabalTest :: String -> [String] -> IO Bool runCabalTest cabalName args = do (_, out, err, _) <- runInteractiveCommand (cabalName ++ " test " ++ unwords args)- outResult <- liftM (not . any isTestFailure) (readLines out)- _ <- readLines err- return outResult+ aOutResult <- checkFailure out stdout+ aErrResult <- checkFailure err stderr+ results <- waitBoth aOutResult aErrResult+ return $ uncurry (&&) results getCabalName :: [String] -> Maybe String getCabalName [] = Just defaultCabalName