Skip to content

Commit e20054b

Browse files
committed
Populate Parsec.Lagacy
1 parent 2757e81 commit e20054b

File tree

2 files changed

+97
-41
lines changed

2 files changed

+97
-41
lines changed

Cabal/Distribution/PackageDescription/Parsec/Legacy.hs

Lines changed: 88 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,79 @@ patches :: Map.Map (BS.ByteString, Fingerprint) (Fingerprint, BS.ByteString -> B
4141
patches = Map.fromList
4242
-- http://hackage.haskell.org/package/unicode-transforms-0.3.3
4343
-- other-modules: .
44+
-- ReadP assumed dot is empty line
4445
[ mk "-- This file has been generated from package.yaml by hpack version 0.17.0.\n--\n-- see: https://github.com/sol/hpack\n\nname: unicode-transforms\nversion: 0.3.3\nsynopsis: Unicode normalization\ndescription: Fast Unic"
4546
(Fingerprint 15958160436627155571 10318709190730872881)
4647
(Fingerprint 11008465475756725834 13815629925116264363)
4748
(bsRemove " other-modules:\n .\n") -- TODO: remove traling \n to test structural-diff
49+
-- http://hackage.haskell.org/package/DSTM-0.1.2
50+
-- http://hackage.haskell.org/package/DSTM-0.1.1
51+
-- http://hackage.haskell.org/package/DSTM-0.1
52+
-- Other Modules: no dash
53+
-- ReadP parsed as section
54+
, mk "Name: DSTM\nVersion: 0.1.2\nCopyright: (c) 2010, Frank Kupke\nLicense: LGPL\nLicense-File: LICENSE\nAuthor: Frank Kupke\nMaintainer: [email protected]\nCabal-Version: >= 1.2.3\nStability: provisional\nSynopsis: A framework for using STM within distributed "
55+
(Fingerprint 6919263071548559054 9050746360708965827)
56+
(Fingerprint 17015177514298962556 11943164891661867280)
57+
(bsReplace "Other modules:" "-- ")
58+
, mk "Name: DSTM\nVersion: 0.1.1\nCopyright: (c) 2010, Frank Kupke\nLicense: LGPL\nLicense-File: LICENSE\nAuthor: Frank Kupke\nMaintainer: [email protected]\nCabal-Version: >= 1.2.3\nStability: provisional\nSynopsis: A framework for using STM within distributed "
59+
(Fingerprint 17313105789069667153 9610429408495338584)
60+
(Fingerprint 17250946493484671738 17629939328766863497)
61+
(bsReplace "Other modules:" "-- ")
62+
, mk "Name: DSTM\nVersion: 0.1\nCopyright: (c) 2010, Frank Kupke\nLicense: LGPL\nLicense-File: LICENSE\nAuthor: Frank Kupke\nMaintainer: [email protected]\nCabal-Version: >= 1.2.3\nStability: provisional\nSynopsis: A framework for using STM within distributed sy"
63+
(Fingerprint 10502599650530614586 16424112934471063115)
64+
(Fingerprint 13562014713536696107 17899511905611879358)
65+
(bsReplace "Other modules:" "-- ")
66+
-- http://hackage.haskell.org/package/control-monad-exception-mtl-0.10.3
67+
, mk "name: control-monad-exception-mtl\nversion: 0.10.3\nCabal-Version: >= 1.10\nbuild-type: Simple\nlicense: PublicDomain\nauthor: Pepe Iborra\nmaintainer: [email protected]\nhomepage: http://pepeiborra.github.com/control-monad-exception\nsynopsis: MTL instances f"
68+
(Fingerprint 18274748422558568404 4043538769550834851)
69+
(Fingerprint 11395257416101232635 4303318131190196308)
70+
(bsReplace " default- extensions:" "unknown-section")
71+
-- http://hackage.haskell.org/package/vacuum-opengl-0.0
72+
-- \DEL character
73+
, mk "Name: vacuum-opengl\nVersion: 0.0\nSynopsis: Visualize live Haskell data structures using vacuum, graphviz and OpenGL.\nDescription: \DELVisualize live Haskell data structures using vacuum, graphviz and OpenGL.\n "
74+
(Fingerprint 5946760521961682577 16933361639326309422)
75+
(Fingerprint 14034745101467101555 14024175957788447824)
76+
(bsRemove "\DEL")
77+
, mk "Name: vacuum-opengl\nVersion: 0.0.1\nSynopsis: Visualize live Haskell data structures using vacuum, graphviz and OpenGL.\nDescription: \DELVisualize live Haskell data structures using vacuum, graphviz and OpenGL.\n "
78+
(Fingerprint 10790950110330119503 1309560249972452700)
79+
(Fingerprint 1565743557025952928 13645502325715033593)
80+
(bsRemove "\DEL")
81+
-- http://hackage.haskell.org/package/ixset-1.0.4
82+
-- {- comments -}
83+
, mk "Name: ixset\nVersion: 1.0.4\nSynopsis: Efficient relational queries on Haskell sets.\nDescription:\n Create and query sets that are indexed by multiple indices.\nLicense: BSD3\nLicense-file: COPYING\nAut"
84+
(Fingerprint 11886092342440414185 4150518943472101551)
85+
(Fingerprint 5731367240051983879 17473925006273577821)
86+
(bsRemoveStarting "{-")
87+
-- : after section
88+
-- http://hackage.haskell.org/package/ds-kanren
89+
, mk "name: ds-kanren\nversion: 0.2.0.0\nsynopsis: A subset of the miniKanren language\ndescription:\n ds-kanren is an implementation of the <http://minikanren.org miniKanren> language.\n .\n == What's in ds-kanren?\n .\n ['dis"
90+
(Fingerprint 2804006762382336875 9677726932108735838)
91+
(Fingerprint 9830506174094917897 12812107316777006473)
92+
(bsReplace "Test-Suite test-unify:" "Test-Suite \"test-unify:\"" . bsReplace "Test-Suite test-list-ops:" "Test-Suite \"test-list-ops:\"")
93+
, mk "name: ds-kanren\nversion: 0.2.0.1\nsynopsis: A subset of the miniKanren language\ndescription:\n ds-kanren is an implementation of the <http://minikanren.org miniKanren> language.\n\nlicense: MIT\nlicense-file: "
94+
(Fingerprint 9130259649220396193 2155671144384738932)
95+
(Fingerprint 1847988234352024240 4597789823227580457)
96+
(bsReplace "Test-Suite test-unify:" "Test-Suite \"test-unify:\"" . bsReplace "Test-Suite test-list-ops:" "Test-Suite \"test-list-ops:\"")
97+
, mk "name: metric\nversion: 0.1.4\nsynopsis: Metric spaces.\nlicense: MIT\nlicense-file: LICENSE\nauthor: Vikram Verma\nmaintainer: [email protected]\ncategory: Data\nbuild-type:"
98+
(Fingerprint 6150019278861565482 3066802658031228162)
99+
(Fingerprint 9124826020564520548 15629704249829132420)
100+
(bsReplace "test-suite metric-tests:" "test-suite \"metric-tests:\"")
101+
, mk "name: metric\nversion: 0.2.0\nsynopsis: Metric spaces.\nlicense: MIT\nlicense-file: LICENSE\nauthor: Vikram Verma\nmaintainer: [email protected]\ncategory: Data\nbuild-type:"
102+
(Fingerprint 4639805967994715694 7859317050376284551)
103+
(Fingerprint 5566222290622325231 873197212916959151)
104+
(bsReplace "test-suite metric-tests:" "test-suite \"metric-tests:\"")
105+
, mk "name: phasechange\ncategory: Data\nversion: 0.1\nauthor: G\195\161bor Lehel\nmaintainer: G\195\161bor Lehel <[email protected]>\nhomepage: http://github.com/glehel/phasechange\ncopyright: Copyright (C) 2012 G\195\161bor Lehel\nlicense: "
106+
(Fingerprint 10546509771395401582 245508422312751943)
107+
(Fingerprint 5169853482576003304 7247091607933993833)
108+
(bsReplace "impl(ghc >= 7.4):" "erroneous-section" . bsReplace "impl(ghc >= 7.6):" "erroneous-section")
109+
, mk "Name: smartword\nSynopsis: Web based flash card for Word Smart I and II vocabularies\nVersion: 0.0.0.5\nHomepage: http://kyagrd.dyndns.org/~kyagrd/project/smartword/\nCategory: Web,Education\nLicense: "
110+
(Fingerprint 7803544783533485151 10807347873998191750)
111+
(Fingerprint 1665635316718752601 16212378357991151549)
112+
(bsReplace "build depends:" "--")
113+
, mk "name: shelltestrunner\n-- sync with README.md, ANNOUNCE:\nversion: 1.3\ncategory: Testing\nsynopsis: A tool for testing command-line programs.\ndescription:\n shelltestrunner is a cross-platform tool for testing command-line\n program"
114+
(Fingerprint 4403237110790078829 15392625961066653722)
115+
(Fingerprint 10218887328390239431 4644205837817510221)
116+
(bsReplace "other modules:" "--")
48117
]
49118
where
50119
mk a b c d = ((a, b), (c, d))
@@ -56,14 +125,14 @@ _makePatchKey fp transform = do
56125
let output = transform contents
57126
let Fingerprint hi lo = md5 contents
58127
let Fingerprint hi' lo' = md5 output
59-
putStrLn
60-
$ showString "mk "
128+
putStrLn
129+
$ showString " , mk "
61130
. shows (BS.take 256 contents)
62-
. showString "\n (Fingerprint "
131+
. showString "\n (Fingerprint "
63132
. shows hi
64133
. showString " "
65134
. shows lo
66-
. showString ")\n (Fingerprint "
135+
. showString ")\n (Fingerprint "
67136
. shows hi'
68137
. showString " "
69138
. shows lo'
@@ -79,3 +148,18 @@ bsRemove
79148
-> BS.ByteString -> BS.ByteString
80149
bsRemove needle haystack = case BS.breakSubstring needle haystack of
81150
(h, t) -> BS.append h (BS.drop (BS.length needle) t)
151+
152+
bsReplace
153+
:: BS.ByteString -- ^ needle
154+
-> BS.ByteString -- ^ replacement
155+
-> BS.ByteString -> BS.ByteString
156+
bsReplace needle repl haystack = case BS.breakSubstring needle haystack of
157+
(h, t)
158+
| not (BS.null t) -> BS.append h (BS.append repl (BS.drop (BS.length needle) t))
159+
| otherwise -> haystack
160+
161+
bsRemoveStarting
162+
:: BS.ByteString -- ^ needle
163+
-> BS.ByteString -> BS.ByteString
164+
bsRemoveStarting needle haystack = case BS.breakSubstring needle haystack of
165+
(h, _) -> h

Cabal/tests/ParserHackageTests.hs

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ compareTest
9595
:: String -- ^ prefix of first packages to start traversal
9696
-> FilePath -> BSL.ByteString -> IO (Sum Int, Sum Int, M Parsec.PWarnType (Sum Int))
9797
compareTest pfx fpath bsl
98-
| any ($ fpath) problematicFiles = mempty
9998
| not $ pfx `isPrefixOf` fpath = mempty
10099
| otherwise = do
101100
let str = ignoreBOM $ fromUTF8LBS bsl
@@ -132,7 +131,8 @@ compareTest pfx fpath bsl
132131
else parsec0
133132

134133
-- Compare two parse results
135-
unless (readp0 == parsec1) $ do
134+
-- ixset-1.0.4 has invalid prof-options, it's the only exception!
135+
unless (readp0 == parsec1 || fpath == "ixset/1.0.4/ixset.cabal") $ do
136136
#if HAS_STRUCT_DIFF
137137
prettyResultIO $ diff readp parsec
138138
#else
@@ -149,20 +149,22 @@ compareTest pfx fpath bsl
149149

150150
when (readpWarnCount > parsecWarnCount) $ do
151151
putStrLn "There are more readpWarnings"
152-
exitFailure
152+
-- hint has -- in brace syntax, readp thinks it's a section
153+
-- http://hackage.haskell.org/package/hint-0.3.2.3/revision/0.cabal
154+
unless ("/hint.cabal" `isSuffixOf` fpath) exitFailure
153155

154156
let parsecWarnMap = foldMap (\(Parsec.PWarning t _ _) -> M $ Map.singleton t 1) warnings
155157
return (readpWarnCount, parsecWarnCount, parsecWarnMap)
156158

157159
parseReadpTest :: FilePath -> BSL.ByteString -> IO ()
158-
parseReadpTest fpath bsl = unless (any ($ fpath) problematicFiles) $ do
159-
let str = fromUTF8LBS bsl
160+
parseReadpTest fpath bsl = do
161+
let str = ignoreBOM $ fromUTF8LBS bsl
160162
case ReadP.parseGenericPackageDescription str of
161163
ReadP.ParseOk _ _ -> return ()
162-
ReadP.ParseFailed err -> print err >> exitFailure
164+
ReadP.ParseFailed err -> putStrLn fpath >> print err >> exitFailure
163165

164166
parseParsecTest :: FilePath -> BSL.ByteString -> IO ()
165-
parseParsecTest fpath bsl = unless (any ($ fpath) problematicFiles) $ do
167+
parseParsecTest fpath bsl = do
166168
let bs = bslToStrict bsl
167169
let (_warnings, errors, parsec) = Parsec.runParseResult $ Parsec.parseGenericPackageDescription bs
168170
case parsec of
@@ -171,36 +173,6 @@ parseParsecTest fpath bsl = unless (any ($ fpath) problematicFiles) $ do
171173
traverse_ (putStrLn . Parsec.showPError fpath) errors
172174
exitFailure
173175

174-
problematicFiles :: [FilePath -> Bool]
175-
problematicFiles =
176-
[
177-
-- Indent failure
178-
eq "control-monad-exception-mtl/0.10.3/control-monad-exception-mtl.cabal"
179-
-- Other modules <- no dash
180-
, eq "DSTM/0.1/DSTM.cabal"
181-
, eq "DSTM/0.1.1/DSTM.cabal"
182-
, eq "DSTM/0.1.2/DSTM.cabal"
183-
-- colon : after section header
184-
, eq "ds-kanren/0.2.0.0/ds-kanren.cabal"
185-
, eq "ds-kanren/0.2.0.1/ds-kanren.cabal"
186-
, eq "metric/0.1.4/metric.cabal"
187-
, eq "metric/0.2.0/metric.cabal"
188-
, eq "phasechange/0.1/phasechange.cabal"
189-
, eq "shelltestrunner/1.3/shelltestrunner.cabal"
190-
, eq "smartword/0.0.0.5/smartword.cabal"
191-
-- \DEL
192-
, eq "vacuum-opengl/0.0/vacuum-opengl.cabal"
193-
, eq "vacuum-opengl/0.0.1/vacuum-opengl.cabal"
194-
-- dashes in version, not even tag
195-
, isPrefixOf "free-theorems-webui/"
196-
-- {- comment -}
197-
, eq "ixset/1.0.4/ixset.cabal"
198-
-- comments in braces
199-
, isPrefixOf "hint/"
200-
]
201-
where
202-
eq = (==)
203-
204176
main :: IO ()
205177
main = do
206178
args <- getArgs

0 commit comments

Comments
 (0)