Skip to content

A makefile to run doctests in Cabal-syntax #8703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Cabal-syntax/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Andreas, 2023-01-26: Makefile for running the doctests.

# Needs `ghc` and `ghc-pkg` in PATH.
# Not clear how to make this multi-GHC ready: https://github.com/sol/doctest/issues/396

# doctest is GHC-specific, so we query the version.
GHC_VERSION = $(shell ghc --numeric-version)

.PHONY: doctest
doctest: install-doctest run-doctest

.PHONY: install-doctest
# doctest only works with the GHC it got installed with.
# So on ghc 9.4.4 we install doctest as doctest-9.4.4.
# `doctest --numeric-version` gives the ghc version it got installed with.
install-doctest:
[[ "$$(doctest-$(GHC_VERSION) --numeric-version)" == "$(GHC_VERSION)" ]] \
|| cabal install --ignore-project --overwrite-policy=always --program-suffix=-$(GHC_VERSION) doctest \
&& [[ "$$(doctest-$(GHC_VERSION) --numeric-version)" == "$(GHC_VERSION)" ]]
# Paranoia: test whether we really got the right version

.PHONY: run-doctest
run-doctest:
cabal repl -w doctest-$(GHC_VERSION) --repl-options=-w

# EOF
2 changes: 1 addition & 1 deletion Cabal-syntax/src/Distribution/Backpack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ instance Pretty OpenUnitId where
-- |
--
-- >>> eitherParsec "foobar" :: Either String OpenUnitId
--Right (DefiniteUnitId (DefUnitId {unDefUnitId = UnitId "foobar"}))
-- Right (DefiniteUnitId (DefUnitId {unDefUnitId = UnitId "foobar"}))
--
-- >>> eitherParsec "foo[Str=text-1.2.3:Data.Text.Text]" :: Either String OpenUnitId
-- Right (IndefFullUnitId (ComponentId "foo") (fromList [(ModuleName "Str",OpenModule (DefiniteUnitId (DefUnitId {unDefUnitId = UnitId "text-1.2.3"})) (ModuleName "Data.Text.Text"))]))
Expand Down
2 changes: 1 addition & 1 deletion Cabal-syntax/src/Distribution/InstalledPackageInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import Distribution.Types.InstalledPackageInfo
import Distribution.Types.InstalledPackageInfo.FieldGrammar

-- $setup
-- >>> :set -XOverloadedStrings
-- >>> :seti -XOverloadedStrings

installedComponentId :: InstalledPackageInfo -> ComponentId
installedComponentId ipi =
Expand Down