Skip to content

Commit 8f83b40

Browse files
committed
Add doctest-% pattern target
1 parent fb48f00 commit 8f83b40

1 file changed

Lines changed: 28 additions & 7 deletions

File tree

Makefile

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,38 @@ ghcid-lib: ## Run ghcid for the Cabal library.
149149
ghcid-cli: ## Run ghcid for the cabal-install executable.
150150
ghcid -c 'cabal repl cabal-install'
151151

152+
# doctests
153+
154+
# To find package directories that might have doctests:
155+
# $ grep --exclude generics-sop-lens.hs -E "\- >>>" **/*.hs | awk -F/ '{print $1}' | sort -u
156+
DOCTEST_PACKAGES := \
157+
Cabal \
158+
Cabal-described \
159+
Cabal-syntax \
160+
cabal-install \
161+
cabal-install-solver \
162+
cabal-testsuite
163+
164+
DOCTEST_TARGETS := $(addprefix doctest-, $(DOCTEST_PACKAGES))
165+
166+
doctest-%: ## Run doctests for a specific package.
167+
@echo "Running doctests for $*:"
168+
@$(DOCTEST) $*
169+
170+
doctest-PACKAGENAME: ## Run doctests for a single package (replace PACKAGENAME).
171+
@echo 'Please use one of the following targets:'
172+
@printf "%s\n" $(DOCTEST_TARGETS)
173+
152174
.PHONY: doctest
153-
doctest: ## Run doctests.
154-
cd Cabal-syntax && $(DOCTEST)
155-
cd Cabal-described && $(DOCTEST)
156-
cd Cabal && $(DOCTEST)
157-
cd cabal-install-solver && $(DOCTEST)
158-
cd cabal-install && $(DOCTEST)
175+
doctest: ## Run doctests in all packages.
176+
doctest: $(DOCTEST_TARGETS)
159177

178+
# We don't use the cabal-doctest external command but we install it anyway along
179+
# with doctest.
180+
# SEE: https://github.com/haskell/cabal/issues/11493
160181
.PHONY: doctest-install
161182
doctest-install: ## Install doctest tool needed for running doctests.
162-
cabal install doctest --overwrite-policy=always --ignore-project --flag cabal-doctest
183+
cabal install doctest-0.24.3 --overwrite-policy=always --ignore-project --flag cabal-doctest
163184

164185
# tests
165186

0 commit comments

Comments
 (0)