Move doctests to shell script

This fixes various problems with doctest:

* https://github.com/sol/doctest/issues/245
* https://github.com/composewell/streamly/issues/83

Also clean up travis.yml for cabal-3.
This commit is contained in:
Julian Ospald 2019-12-30 21:55:55 +01:00
parent 3529ec2a15
commit f5c541b9cc
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
5 changed files with 36 additions and 98 deletions

View File

@ -7,18 +7,18 @@ dist: trusty
matrix: matrix:
include: include:
- env: CABALVER=2.2 GHCVER=7.6.3 - env: CABALVER=3.0 GHCVER=7.6.3 SKIP_DOCTESTS=yes
addons: {apt: {packages: [cabal-install-2.2,ghc-7.6.3], sources: [hvr-ghc]}} addons: {apt: {packages: [cabal-install-3.0,ghc-7.6.3], sources: [hvr-ghc]}}
- env: CABALVER=2.2 GHCVER=7.8.4 - env: CABALVER=3.0 GHCVER=7.8.4 SKIP_DOCTESTS=yes
addons: {apt: {packages: [cabal-install-2.2,ghc-7.8.4], sources: [hvr-ghc]}} addons: {apt: {packages: [cabal-install-3.0,ghc-7.8.4], sources: [hvr-ghc]}}
- env: CABALVER=2.2 GHCVER=7.10.2 - env: CABALVER=3.0 GHCVER=7.10.2 SKIP_DOCTESTS=yes
addons: {apt: {packages: [cabal-install-2.2,ghc-7.10.2], sources: [hvr-ghc]}} addons: {apt: {packages: [cabal-install-3.0,ghc-7.10.2], sources: [hvr-ghc]}}
- env: CABALVER=2.2 GHCVER=8.0.1 - env: CABALVER=3.0 GHCVER=8.0.1 SKIP_DOCTESTS=yes
addons: {apt: {packages: [cabal-install-2.2,ghc-8.0.1], sources: [hvr-ghc]}} addons: {apt: {packages: [cabal-install-3.0,ghc-8.0.1], sources: [hvr-ghc]}}
- env: CABALVER=2.2 GHCVER=8.2.2 - env: CABALVER=3.0 GHCVER=8.2.2
addons: {apt: {packages: [cabal-install-2.2,ghc-8.2.2], sources: [hvr-ghc]}} addons: {apt: {packages: [cabal-install-3.0,ghc-8.2.2], sources: [hvr-ghc]}}
- env: CABALVER=2.2 GHCVER=8.4.1 - env: CABALVER=3.0 GHCVER=8.4.1
addons: {apt: {packages: [cabal-install-2.2,ghc-8.4.1], sources: [hvr-ghc]}} addons: {apt: {packages: [cabal-install-3.0,ghc-8.4.1], sources: [hvr-ghc]}}
- env: CABALVER=head GHCVER=head - env: CABALVER=head GHCVER=head
addons: {apt: {packages: [cabal-install-head,ghc-head], sources: [hvr-ghc]}} addons: {apt: {packages: [cabal-install-head,ghc-head], sources: [hvr-ghc]}}
@ -36,27 +36,15 @@ before_install:
install: install:
- cabal --version - cabal --version
- travis_retry cabal update - travis_retry cabal update
- cabal sandbox init
- cabal install --only-dependencies --enable-tests -j
script: script:
- cabal configure --enable-tests -v2
- cabal build - cabal build
- cabal test - cabal test
- ./run-doctests.sh
- cabal check - cabal check
- cabal sdist - cabal sdist
- cabal haddock --hyperlink-source --html-location=https://hackage.haskell.org/package/\$pkg-\$version/docs/ - cabal haddock --hyperlink-source --html-location=https://hackage.haskell.org/package/\$pkg-\$version/docs/
# check that the generated source-distribution can be built & installed - cabal install --enable-tests --lib
- export SRC_TGZ=$(cabal info . | awk '{print $2 ".tar.gz";exit}') ;
cd dist/;
cabal sandbox init;
if [ -f "$SRC_TGZ" ]; then
cabal install "$SRC_TGZ" --enable-tests;
else
echo "expected '$SRC_TGZ' not found";
exit 1;
fi;
cd ..
after_script: after_script:
- ./update-gh-pages.sh - ./update-gh-pages.sh

View File

@ -1,13 +0,0 @@
module Main where
import Test.DocTest
import Test.HUnit
main =
doctest
["-isrc"
, "-XOverloadedStrings"
, "src/HPath.hs"
]

View File

@ -1,25 +0,0 @@
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Applicative
import System.Posix.Directory.Traversals
import Test.DocTest
import Test.HUnit
main = do
doctest
[ "-isrc"
, "-XOverloadedStrings"
, "System.Posix.FilePath"
]
runTestTT unitTests
unitTests :: Test
unitTests = test
[ TestCase $ do
r <- (==) <$> allDirectoryContents "." <*> allDirectoryContents' "."
assertBool "allDirectoryContents == allDirectoryContents'" r
]

View File

@ -13,8 +13,6 @@ cabal-version: 1.14
extra-source-files: README.md extra-source-files: README.md
CHANGELOG CHANGELOG
cbits/dirutils.h cbits/dirutils.h
doctests-hpath.hs
doctests-posix.hs
library library
if os(windows) if os(windows)
@ -41,7 +39,6 @@ library
, deepseq , deepseq
, exceptions , exceptions
, hspec , hspec
, simple-sendfile >= 0.2.24
, streamly >= 0.7 , streamly >= 0.7
, unix >= 2.5 , unix >= 2.5
, unix-bytestring , unix-bytestring
@ -49,37 +46,6 @@ library
, word8 , word8
test-suite doctests-hpath
if os(windows)
build-depends: unbuildable<0
buildable: False
default-language: Haskell2010
type: exitcode-stdio-1.0
ghc-options: -threaded
main-is: doctests-hpath.hs
build-depends: base
, HUnit
, QuickCheck
, doctest >= 0.8
, hpath
test-suite doctests-posix
if os(windows)
build-depends: unbuildable<0
buildable: False
default-language: Haskell2010
type: exitcode-stdio-1.0
ghc-options: -threaded
main-is: doctests-posix.hs
build-depends: base,
bytestring >= 0.10.0.0,
unix,
hpath,
doctest >= 0.8,
HUnit,
QuickCheck,
word8
test-suite spec test-suite spec
if os(windows) if os(windows)
build-depends: unbuildable<0 build-depends: unbuildable<0

22
run-doctests.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
set -e
if [ -n "${SKIP_DOCTESTS}" ] ; then
echo "Skipping doctests"
exit 0
fi
if ! command -v doctest >/dev/null ; then
tempdir="$(mktemp -d)"
(
cd "${tempdir}"
cabal install --installdir="${tempdir}" doctest
)
export PATH="${tempdir}:$PATH"
fi
set -x
cabal exec doctest -- -isrc -XOverloadedStrings System.Posix.FilePath
cabal exec doctest -- -isrc -XOverloadedStrings HPath