Skip to content

Commit 1b4f509

Browse files
committed
Run doctest as part of validate.sh
1 parent 70d22dd commit 1b4f509

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

.docker/validate-8.8.1.dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ RUN cabal v2-install cabal-plan --constraint 'cabal-plan ^>=0.6'
66

77
# We install happy, so it's in the store; we (hopefully) don't use it directly.
88
RUN cabal v2-install happy --constraint 'happy ^>=1.19.12'
9+
RUN cabal v2-install doctest --constraint 'doctest ^>= 0.16.2'
910

1011
# Install some other dependencies
1112
# Remove $HOME/.ghc so there aren't any environments
@@ -41,4 +42,4 @@ RUN cabal v2-install -w ghc-8.8.1 --lib \
4142
# Validate
4243
WORKDIR /build
4344
COPY . /build
44-
RUN sh ./validate.sh -w ghc-8.8.1 -v
45+
RUN sh ./validate.sh -w ghc-8.8.1 -v -D

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
cabal.project.local
44
.ghc.environment.*
55

6+
.docker/
7+
68
**/.hpc
79
**/*.hi
810
**/*.o

validate.sh

+22-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ CABALINSTALLTESTS=true
1313
CABALSUITETESTS=true
1414
CABALONLY=false
1515
DEPSONLY=false
16+
DOCTEST=false
1617
VERBOSE=false
1718

1819
# Help
@@ -22,7 +23,7 @@ show_usage() {
2223
cat <<EOF
2324
./validate.sh - build & test
2425
25-
Usage: ./validate.sh [ -j JOBS | -l | -C | -c | -s | -w HC | -x CABAL | -y CABALPLAN | -d | -v ]
26+
Usage: ./validate.sh [ -j JOBS | -l | -C | -c | -s | -w HC | -x CABAL | -y CABALPLAN | -d | -D | -v ]
2627
A script which runs all the tests.
2728
2829
Available options:
@@ -35,6 +36,7 @@ Available options:
3536
-x CABAL With cabal-install
3637
-y CABALPLAN With cabal-plan
3738
-d Build dependencies only
39+
-D Run doctest
3840
-v Verbose
3941
EOF
4042
exit 0
@@ -110,7 +112,7 @@ footer() {
110112
# getopt
111113
#######################################################################
112114

113-
while getopts 'j:lCcsw:x:y:dv' flag; do
115+
while getopts 'j:lCcsw:x:y:dDv' flag; do
114116
case $flag in
115117
j) JOBS="$OPTARG"
116118
;;
@@ -130,6 +132,8 @@ while getopts 'j:lCcsw:x:y:dv' flag; do
130132
;;
131133
d) DEPSONLY=true
132134
;;
135+
D) DOCTEST=true
136+
;;
133137
v) VERBOSE=true
134138
;;
135139
?) show_usage
@@ -165,6 +169,7 @@ cabal-install tests: $CABALINSTALLTESTS
165169
cabal-testsuite: $CABALSUITETESTS
166170
library only: $CABALONLY
167171
dependencies only: $DEPSONLY
172+
doctest: $DOCTEST
168173
verbose: $VERBOSE
169174
170175
EOF
@@ -237,6 +242,21 @@ timed $CABALNEWBUILD Cabal:lib:Cabal --enable-tests --disable-benchmarks --dry-r
237242
timed $CABALNEWBUILD Cabal:lib:Cabal --enable-tests --disable-benchmarks --dep || exit 1
238243
timed $CABALNEWBUILD Cabal:lib:Cabal --enable-tests --disable-benchmarks || exit 1
239244

245+
if $DOCTEST; then
246+
if command -v doctest >/dev/null; then
247+
echo "$CYAN=== Cabal: doctest ===================================== $(date +%T) === $RESET"
248+
249+
timed $CABALNEWBUILD Cabal:lib:Cabal --enable-tests --disable-benchmarks --write-ghc-environment-files=always || exit 1
250+
timed doctest --fast Cabal/Distribution Cabal/Language
251+
timed rm -f .ghc.environment.*
252+
253+
else
254+
255+
echo "No doctest command found"
256+
257+
fi # command -v doctest
258+
fi # DOCTEST
259+
240260
if $CABALTESTS; then
241261
echo "$CYAN=== Cabal: test ======================================== $(date +%T) === $RESET"
242262

0 commit comments

Comments
 (0)