Skip to content

Commit

Permalink
Add forEachGPD to hackage-tests
Browse files Browse the repository at this point in the history
This allows to quickly write ad-hoc queries over Hackage
data.
  • Loading branch information
phadej committed Mar 21, 2020
1 parent c52fdf7 commit ec0e1d3
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 ec0e1d3

Please sign in to comment.