Skip to content

Commit 555b25a

Browse files
authored
Merge pull request #9572 from cabalism/fix/doctests-described-8734
Add Cabal-described and cabal-install to doctests
2 parents ce5d0f7 + 8dd381e commit 555b25a

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

Cabal-described/src/Distribution/Utils/CharSet.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,8 @@ alphanum = foldl' (flip insert) empty [ c | c <- [ minBound .. maxBound ], isAlp
240240
upper :: CharSet
241241
upper = foldl' (flip insert) empty [ c | c <- [ minBound .. maxBound ], isUpper c ]
242242
{-# NOINLINE upper #-}
243+
244+
-- $setup
245+
-- Use -XOverloadedStrings to avoid the error: Couldn't match type ‘[Char]’ with ‘CharSet’
246+
-- >>> :set -XOverloadedStrings
247+
-- >>> import Prelude (length)

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
CABALBUILD := cabal build
55
CABALRUN := cabal run
6+
DOCTEST := cabal repl --with-ghc=doctest --repl-options="-w" --project-file=cabal.project.doctest
67

78
# default rules
89

@@ -85,9 +86,10 @@ ghcid-cli :
8586
# https://github.com/haskell/cabal/issues/8734
8687
# Just as well, cabal-install(-solver) doctests (the target below) bitrotted and need some care.
8788
doctest :
88-
cabal repl --with-ghc=doctest --build-depends=QuickCheck --build-depends=template-haskell --repl-options="-w" --project-file="cabal.project.doctest" Cabal-syntax
89-
cabal repl --with-ghc=doctest --build-depends=QuickCheck --build-depends=template-haskell --repl-options="-w" --project-file="cabal.project.doctest" Cabal
90-
89+
$(DOCTEST) Cabal-syntax
90+
$(DOCTEST) Cabal-described
91+
$(DOCTEST) --build-depends=QuickCheck Cabal
92+
$(DOCTEST) cabal-install
9193

9294
# This is not run as part of validate.sh (we need hackage-security, which is tricky to get).
9395
doctest-cli :

cabal-install/src/Distribution/Client/IndexUtils/ActiveRepos.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ instance Pretty ActiveRepos where
7070
-- Just (ActiveRepos [ActiveRepoRest CombineStrategyMerge])
7171
--
7272
-- >>> simpleParsec "hackage.haskell.org, :rest, head.hackage:override" :: Maybe ActiveRepos
73-
-- Just (ActiveRepos [ActiveRepo (RepoName "hackage.haskell.org") CombineStrategyMerge,ActiveRepoRest CombineStrategyMerge,ActiveRepo (RepoName "head.hackage") CombineStrategyOverride])
73+
-- Just (ActiveRepos [ActiveRepo (RepoName {unRepoName = "hackage.haskell.org"}) CombineStrategyMerge,ActiveRepoRest CombineStrategyMerge,ActiveRepo (RepoName {unRepoName = "head.hackage"}) CombineStrategyOverride])
7474
instance Parsec ActiveRepos where
7575
parsec =
7676
ActiveRepos [] <$ P.try (P.string ":none")
@@ -148,13 +148,13 @@ instance Parsec CombineStrategy where
148148
--
149149
-- >>> let repos = [RepoName "a", RepoName "b", RepoName "c"]
150150
-- >>> organizeByRepos (ActiveRepos [ActiveRepoRest CombineStrategyMerge]) id repos
151-
-- Right [(RepoName "a",CombineStrategyMerge),(RepoName "b",CombineStrategyMerge),(RepoName "c",CombineStrategyMerge)]
151+
-- Right [(RepoName {unRepoName = "a"},CombineStrategyMerge),(RepoName {unRepoName = "b"},CombineStrategyMerge),(RepoName {unRepoName = "c"},CombineStrategyMerge)]
152152
--
153153
-- >>> organizeByRepos (ActiveRepos [ActiveRepo (RepoName "b") CombineStrategyOverride, ActiveRepoRest CombineStrategyMerge]) id repos
154-
-- Right [(RepoName "b",CombineStrategyOverride),(RepoName "a",CombineStrategyMerge),(RepoName "c",CombineStrategyMerge)]
154+
-- Right [(RepoName {unRepoName = "b"},CombineStrategyOverride),(RepoName {unRepoName = "a"},CombineStrategyMerge),(RepoName {unRepoName = "c"},CombineStrategyMerge)]
155155
--
156156
-- >>> organizeByRepos (ActiveRepos [ActiveRepoRest CombineStrategyMerge, ActiveRepo (RepoName "b") CombineStrategyOverride]) id repos
157-
-- Right [(RepoName "a",CombineStrategyMerge),(RepoName "c",CombineStrategyMerge),(RepoName "b",CombineStrategyOverride)]
157+
-- Right [(RepoName {unRepoName = "a"},CombineStrategyMerge),(RepoName {unRepoName = "c"},CombineStrategyMerge),(RepoName {unRepoName = "b"},CombineStrategyOverride)]
158158
--
159159
-- >>> organizeByRepos (ActiveRepos [ActiveRepoRest CombineStrategyMerge, ActiveRepo (RepoName "d") CombineStrategyOverride]) id repos
160160
-- Left "no repository provided d"

cabal-install/src/Distribution/Client/IndexUtils/IndexState.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ instance Pretty TotalIndexState where
6868
-- Just (TIS IndexStateHead (fromList []))
6969
--
7070
-- >>> simpleParsec "2020-02-04T12:34:56Z, hackage.haskell.org HEAD" :: Maybe TotalIndexState
71-
-- Just (TIS (IndexStateTime (TS 1580819696)) (fromList [(RepoName "hackage.haskell.org",IndexStateHead)]))
71+
-- Just (TIS (IndexStateTime (TS 1580819696)) (fromList [(RepoName {unRepoName = "hackage.haskell.org"},IndexStateHead)]))
7272
--
7373
-- >>> simpleParsec "hackage.haskell.org 2020-02-04T12:34:56Z" :: Maybe TotalIndexState
74-
-- Just (TIS IndexStateHead (fromList [(RepoName "hackage.haskell.org",IndexStateTime (TS 1580819696))]))
74+
-- Just (TIS IndexStateHead (fromList [(RepoName {unRepoName = "hackage.haskell.org"},IndexStateTime (TS 1580819696))]))
7575
instance Parsec TotalIndexState where
7676
parsec = normalise . foldl' add headTotalIndexState <$> parsecLeadingCommaNonEmpty single0
7777
where

cabal-install/src/Distribution/Client/Types/RepoName.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ instance Pretty RepoName where
2929
-- |
3030
--
3131
-- >>> simpleParsec "hackage.haskell.org" :: Maybe RepoName
32-
-- Just (RepoName "hackage.haskell.org")
32+
-- Just (RepoName {unRepoName = "hackage.haskell.org"})
3333
--
3434
-- >>> simpleParsec "0123" :: Maybe RepoName
3535
-- Nothing

0 commit comments

Comments
 (0)