hpc-coveralls 0.8.1 → 0.8.2
raw patch · 8 files changed
+34/−15 lines, 8 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Trace.Hpc.Coveralls.Util: mcons :: Maybe a -> [a] -> [a]
Files
- CHANGELOG.md +4/−0
- README.md +4/−0
- hpc-coveralls.cabal +1/−1
- src/HpcCoverallsCmdLine.hs +8/−6
- src/HpcCoverallsMain.hs +1/−1
- src/Trace/Hpc/Coveralls.hs +11/−7
- src/Trace/Hpc/Coveralls/Config.hs +1/−0
- src/Trace/Hpc/Coveralls/Util.hs +4/−0
CHANGELOG.md view
@@ -1,3 +1,7 @@+[0.8.2](https://github.com/guillaume-nargeot/hpc-coveralls/issues?q=milestone:v0.8.2+is:closed)+-----+* Add option to send repo token (issue #36)+ [0.8.1](https://github.com/guillaume-nargeot/hpc-coveralls/issues?q=milestone:v0.8.1+is:closed) ----- * Include additional test modules in package generated by sdist (issue #34)
README.md view
@@ -117,6 +117,10 @@ Please also note that there is an [open issue](https://github.com/lemurheavy/coveralls-public/issues/216) on coveralls issue tracker in order to improve this (add support for partial line coverage). +#### --repo-token++This option allows to specify your repo token when sending the report to coveralls.io.+ #### --display-report This boolean option prints the raw json coverage report to be sent to coveralls.io.
hpc-coveralls.cabal view
@@ -1,5 +1,5 @@ name: hpc-coveralls-version: 0.8.1+version: 0.8.2 synopsis: Coveralls.io support for Haskell. description: This utility converts and sends Haskell projects hpc code coverage to
src/HpcCoverallsCmdLine.hs view
@@ -11,6 +11,7 @@ data HpcCoverallsArgs = CmdMain { excludeDirs :: [String] , testSuites :: [String]+ , repoToken :: Maybe String , displayReport :: Bool , printResponse :: Bool , dontSend :: Bool@@ -19,12 +20,13 @@ hpcCoverallsArgs :: HpcCoverallsArgs hpcCoverallsArgs = CmdMain- { excludeDirs = [] &= explicit &= typDir &= name "exclude-dir" &= help "Exclude sources files under the matching directory from the coverage report"- , displayReport = False &= explicit &= name "display-report" &= help "Display the json code coverage report that will be sent to coveralls.io"- , printResponse = False &= explicit &= name "print-response" &= help "Prints the json reponse received from coveralls.io"- , dontSend = False &= explicit &= name "dont-send" &= help "Do not send the report to coveralls.io"- , coverageMode = AllowPartialLines &= explicit &= typ "MODE" &= name "coverage-mode" &= help "Coverage conversion mode: AllowPartialLines (default), StrictlyFullLines"- , testSuites = [] &= typ "TEST-SUITE" &= args+ { excludeDirs = [] &= explicit &= typDir &= name "exclude-dir" &= help "Exclude sources files under the matching directory from the coverage report"+ , displayReport = False &= explicit &= name "display-report" &= help "Display the json code coverage report that will be sent to coveralls.io"+ , printResponse = False &= explicit &= name "print-response" &= help "Prints the json reponse received from coveralls.io"+ , dontSend = False &= explicit &= name "dont-send" &= help "Do not send the report to coveralls.io"+ , coverageMode = AllowPartialLines &= explicit &= typ "MODE" &= name "coverage-mode" &= help "Coverage conversion mode: AllowPartialLines (default), StrictlyFullLines"+ , repoToken = Nothing &= explicit &= typ "TOKEN" &= name "repo-token" &= help "Coveralls repo token"+ , testSuites = [] &= typ "TEST-SUITES" &= args } &= summary ("hpc-coveralls-" ++ versionString version ++ ", (C) Guillaume Nargeot 2014-2015") &= program "hpc-coveralls" where versionString = intercalate "." . map show . versionBranch
src/HpcCoverallsMain.hs view
@@ -38,7 +38,7 @@ writeJson filePath = BSL.writeFile filePath . encode getConfig :: HpcCoverallsArgs -> Maybe Config-getConfig hca = Config (excludeDirs hca) (coverageMode hca) <$> listToMaybe (testSuites hca)+getConfig hca = Config (excludeDirs hca) (coverageMode hca) (repoToken hca) <$> listToMaybe (testSuites hca) main :: IO () main = do
src/Trace/Hpc/Coveralls.hs view
@@ -11,6 +11,7 @@ module Trace.Hpc.Coveralls ( generateCoverallsFromTix ) where +import Control.Applicative import Data.Aeson import Data.Aeson.Types () import Data.Function@@ -82,12 +83,14 @@ Mix _ _ _ _ mixEntries = mix getExprSource' = getExprSource $ lines source -toCoverallsJson :: String -> String -> LixConverter -> TestSuiteCoverageData -> Value-toCoverallsJson serviceName jobId converter testSuiteCoverageData = object [- "service_job_id" .= jobId,- "service_name" .= serviceName,- "source_files" .= toJsonCoverageList testSuiteCoverageData]- where toJsonCoverageList = map (uncurry $ coverageToJson converter) . M.toList+toCoverallsJson :: String -> String -> Maybe String -> LixConverter -> TestSuiteCoverageData -> Value+toCoverallsJson serviceName jobId repoTokenM converter testSuiteCoverageData =+ object $ mcons (("repo_token" .=) <$> repoTokenM) base+ where base = [+ "service_job_id" .= jobId,+ "service_name" .= serviceName,+ "source_files" .= toJsonCoverageList testSuiteCoverageData]+ toJsonCoverageList = map (uncurry $ coverageToJson converter) . M.toList mergeModuleCoverageData :: ModuleCoverageData -> ModuleCoverageData -> ModuleCoverageData mergeModuleCoverageData (source, mix, tixs1) (_, _, tixs2) =@@ -125,9 +128,10 @@ -> IO Value -- ^ code coverage result in json format generateCoverallsFromTix serviceName jobId config = do testSuitesCoverages <- mapM (`readCoverageData` excludedDirPatterns) testSuiteNames- return $ toCoverallsJson serviceName jobId converter $ mergeCoverageData testSuitesCoverages+ return $ toCoverallsJson serviceName jobId repoTokenM converter $ mergeCoverageData testSuitesCoverages where excludedDirPatterns = excludedDirs config testSuiteNames = testSuites config+ repoTokenM = repoToken config converter = case coverageMode config of StrictlyFullLines -> strictConverter AllowPartialLines -> looseConverter
src/Trace/Hpc/Coveralls/Config.hs view
@@ -5,5 +5,6 @@ data Config = Config { excludedDirs :: ![FilePath], coverageMode :: !CoverageMode,+ repoToken :: !(Maybe String), testSuites :: ![String] }
src/Trace/Hpc/Coveralls/Util.hs view
@@ -30,6 +30,10 @@ listToMaybe [] = Nothing listToMaybe xs = Just xs +mcons :: Maybe a -> [a] -> [a]+mcons Nothing xs = xs+mcons (Just x) xs = x : xs+ matchAny :: [String] -> String -> Bool matchAny patterns fileName = any (`isPrefixOf` fileName) patterns