Skip to content

Commit

Permalink
Re #429: doctests via cabal repl -w doctest
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasabel committed Dec 16, 2022
1 parent 58f397c commit 8c29c2f
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 56 deletions.
108 changes: 55 additions & 53 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,51 +39,51 @@ jobs:
compilerVersion: 9.4.3
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.2.5
compilerKind: ghc
compilerVersion: 9.2.5
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.0.2
compilerKind: ghc
compilerVersion: 9.0.2
setup-method: ghcup
allow-failure: false
- compiler: ghc-8.10.7
compilerKind: ghc
compilerVersion: 8.10.7
setup-method: ghcup
allow-failure: false
- compiler: ghc-8.8.4
compilerKind: ghc
compilerVersion: 8.8.4
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-8.6.5
compilerKind: ghc
compilerVersion: 8.6.5
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-8.4.4
compilerKind: ghc
compilerVersion: 8.4.4
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-8.2.2
compilerKind: ghc
compilerVersion: 8.2.2
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-8.0.2
compilerKind: ghc
compilerVersion: 8.0.2
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-7.10.3
compilerKind: ghc
compilerVersion: 7.10.3
setup-method: hvr-ppa
allow-failure: false
# - compiler: ghc-9.2.5
# compilerKind: ghc
# compilerVersion: 9.2.5
# setup-method: ghcup
# allow-failure: false
# - compiler: ghc-9.0.2
# compilerKind: ghc
# compilerVersion: 9.0.2
# setup-method: ghcup
# allow-failure: false
# - compiler: ghc-8.10.7
# compilerKind: ghc
# compilerVersion: 8.10.7
# setup-method: ghcup
# allow-failure: false
# - compiler: ghc-8.8.4
# compilerKind: ghc
# compilerVersion: 8.8.4
# setup-method: hvr-ppa
# allow-failure: false
# - compiler: ghc-8.6.5
# compilerKind: ghc
# compilerVersion: 8.6.5
# setup-method: hvr-ppa
# allow-failure: false
# - compiler: ghc-8.4.4
# compilerKind: ghc
# compilerVersion: 8.4.4
# setup-method: hvr-ppa
# allow-failure: false
# - compiler: ghc-8.2.2
# compilerKind: ghc
# compilerVersion: 8.2.2
# setup-method: hvr-ppa
# allow-failure: false
# - compiler: ghc-8.0.2
# compilerKind: ghc
# compilerVersion: 8.0.2
# setup-method: hvr-ppa
# allow-failure: false
# - compiler: ghc-7.10.3
# compilerKind: ghc
# compilerVersion: 7.10.3
# setup-method: hvr-ppa
# allow-failure: false
fail-fast: false
steps:
- name: apt
Expand All @@ -96,15 +96,15 @@ jobs:
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml;
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.3.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
else
apt-add-repository -y 'ppa:hvr/ghc'
apt-get update
apt-get install -y "$HCNAME"
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.18.0/x86_64-linux-ghcup-0.1.18.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.3.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
fi
env:
HCKIND: ${{ matrix.compilerKind }}
Expand All @@ -122,13 +122,13 @@ jobs:
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV"
echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.3.0 -vnormal+nowrap" >> "$GITHUB_ENV"
else
HC=$HCDIR/bin/$HCKIND
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV"
echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.3.0 -vnormal+nowrap" >> "$GITHUB_ENV"
fi
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
Expand Down Expand Up @@ -176,10 +176,6 @@ jobs:
active-repositories: hackage.haskell.org, head.hackage.ghc.haskell.org:override
EOF
fi
cat >> $CABAL_CONFIG <<EOF
program-default-options
ghc-options: $GHCJOBS +RTS -M3G -RTS
EOF
cat $CABAL_CONFIG
- name: versions
run: |
Expand Down Expand Up @@ -259,6 +255,12 @@ jobs:
- name: build
run: |
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always
- name: install doctest
run: |
$CABAL install $ARG_COMPILER doctest --overwrite-policy=always
- name: doctests
run: |
$CABAL repl BNFC --with-ghc-pkg=$HCPKG -w doctest
- name: tests
run: |
$CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct
Expand Down
18 changes: 15 additions & 3 deletions source/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,30 @@ BDIST_TAG=bnfc-${BNFC_VERSION}-$(shell uname -s)-$(shell uname -m)

.PHONY: default build install doc test bdist show-version debug weed TAGS

default: build test
default: build cabal-test doctest-quick

build:
$(CABAL_BUILD)

install:
$(CABAL_INSTALL)

test:
test: build cabal-test doctest

cabal-test:
$(CABAL_TEST)

haddock doc:
doctest: build doctest-install doctest-quick

doctest-install:
cabal install doctest --program-suffix=-${GHC_VERSION}

doctest-quick:
cabal repl -w doctest-${GHC_VERSION}
# --ghc-options=-Wno-type-defaults needed? due to OverloadedStrings
# see: https://github.com/sol/doctest/issues/390

haddock:
$(CABAL) haddock

# See https://hackage.haskell.org/package/weeder
Expand Down

0 comments on commit 8c29c2f

Please sign in to comment.