Skip to content

Commit

Permalink
Merge pull request #6598 from phadej/testing
Browse files Browse the repository at this point in the history
Add forEachGPD to hackage-tests
  • Loading branch information
phadej authored Mar 21, 2020
2 parents eba38fc + ec0e1d3 commit 03f211c
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Cabal/tests/HackageTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,26 @@ readFieldTest fpath bs = case Parsec.readFields bs' of

parseParsecTest :: Bool -> FilePath -> B.ByteString -> IO ThreeInt
parseParsecTest keepGoing fpath bs = do
let (warnings, parsec) = Parsec.runParseResult $
Parsec.parseGenericPackageDescription bs
let (warnings, result) = Parsec.runParseResult $
Parsec.parseGenericPackageDescription bs

let w | null warnings = 0
| otherwise = 1

case parsec of
Right _ -> return (ThreeInt 1 w 0)
Left (_, errors) | keepGoing -> return (ThreeInt 1 w 1)
| otherwise -> do
case result of
Right gpd -> do
forEachGPD fpath bs gpd
return (ThreeInt 1 w 0)

Left (_, errors) | keepGoing -> return (ThreeInt 1 w 1)
| otherwise -> do
traverse_ (putStrLn . Parsec.showPError fpath) errors
exitFailure

-- | A hook to make queries on Hackage
forEachGPD :: FilePath -> B8.ByteString -> L.GenericPackageDescription -> IO ()
forEachGPD _ _ _ = return ()

-------------------------------------------------------------------------------
-- ThreeInt
-------------------------------------------------------------------------------
Expand Down

0 comments on commit 03f211c

Please sign in to comment.