diff --git a/Makefile b/Makefile index a9b9ee5e71f..b717400370e 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,8 @@ CABALBUILD := cabal build CABALRUN := cabal run -DOCTEST := cabal doctest +CABAL_DOCTEST := cabal doctest +REPL_WITH_DOCTEST := cabal repl --with-compiler=doctest --build-depends=QuickCheck --verbose=0 --repl-options='-w -Wdefault -Wno-inconsistent-flags' # default rules @@ -149,17 +150,40 @@ ghcid-lib: ## Run ghcid for the Cabal library. ghcid-cli: ## Run ghcid for the cabal-install executable. ghcid -c 'cabal repl cabal-install' +# doctests + +# To find package directories that might have doctests: +# $ grep --exclude generics-sop-lens.hs -E "\- >>>" **/*.hs | awk -F/ '{print $1}' | sort -u +DOCTEST_PACKAGES := \ + Cabal \ + Cabal-described \ + Cabal-syntax \ + cabal-install \ + cabal-install-solver \ + cabal-testsuite + +DOCTEST_TARGETS := $(addprefix doctest-, $(DOCTEST_PACKAGES)) + +doctest-%: ## Run doctests for a specific package. + @echo "Running doctests for $*:" && cd $* && $(CABAL_DOCTEST) $* + +doctest-cabal-testsuite: ## Run doctests for a specific package. + @echo "Running doctests for cabal-testsuite:" && $(REPL_WITH_DOCTEST) cabal-testsuite + +doctest-PACKAGENAME: ## Run doctests for a single package (replace PACKAGENAME). + @echo 'Please use one of the following targets:' + @printf "%s\n" $(DOCTEST_TARGETS) + .PHONY: doctest -doctest: ## Run doctests. - cd Cabal-syntax && $(DOCTEST) - cd Cabal-described && $(DOCTEST) - cd Cabal && $(DOCTEST) - cd cabal-install-solver && $(DOCTEST) - cd cabal-install && $(DOCTEST) +doctest: ## Run doctests in all packages. +doctest: $(DOCTEST_TARGETS) +# We don't use the cabal-doctest external command but we install it anyway along +# with doctest. +# SEE: https://github.com/haskell/cabal/issues/11493 .PHONY: doctest-install doctest-install: ## Install doctest tool needed for running doctests. - cabal install doctest --overwrite-policy=always --ignore-project --flag cabal-doctest + cabal install doctest-0.24.3 --overwrite-policy=always --ignore-project --flag cabal-doctest # tests