diff --git a/scripts/lib/common.sh b/scripts/lib/common.sh index 19b85d5d..bbf3a25a 100644 --- a/scripts/lib/common.sh +++ b/scripts/lib/common.sh @@ -15,6 +15,7 @@ DRY_RUN=false POSITION="none" SOURCES_TXT="$( dirname $DIR)/sources.txt" CABAL=${CABAL:-cabal} +TRAVIS=${TRAVIS:-false} declare -a SOURCES readarray -t SOURCES < "$SOURCES_TXT" @@ -29,3 +30,26 @@ versions_equal () { echo "versions of packages are not all the same!" && exit 1 fi } + +travis_retry() { + # From + # https://github.com/travis-ci/travis-build/blob/18bd04e965b9bfaa49cd6bdcd8dcb1513b8d2fcd/lib/travis/build/templates/header.sh + local result=0 + local count=1 + while [ $count -le 3 ]; do + [ $result -ne 0 ] && { + echo -e "\n${ANSI_RED}The command \"$@\" failed. Retrying, $count of 3.${ANSI_RESET}\n" >&2 + } + "$@" + result=$? + [ $result -eq 0 ] && break + count=$(($count + 1)) + sleep 1 + done + + [ $count -gt 3 ] && { + echo -e "\n${ANSI_RED}The command \"$@\" failed 3 times.${ANSI_RESET}\n" >&2 + } + + return $result +} diff --git a/scripts/test-all.sh b/scripts/test-all.sh index 5c78312c..a8a66e99 100755 --- a/scripts/test-all.sh +++ b/scripts/test-all.sh @@ -24,7 +24,11 @@ prepare_sandbox () { for s in ${SOURCES[@]} ; do (cd "$s" && $CABAL sandbox init --sandbox=../.cabal-sandbox/ && $CABAL sandbox add-source .) done - $CABAL install --enable-tests ${SOURCES[@]} + if $TRAVIS ; then + travis_retry $CABAL install -v --enable-tests ${SOURCES[@]} + else + $CABAL install --enable-tests ${SOURCES[@]} + fi } test_each () { diff --git a/servant/test/Servant/API/ContentTypesSpec.hs b/servant/test/Servant/API/ContentTypesSpec.hs index 0f4a075a..407ccdb9 100644 --- a/servant/test/Servant/API/ContentTypesSpec.hs +++ b/servant/test/Servant/API/ContentTypesSpec.hs @@ -12,8 +12,6 @@ import Data.Monoid #endif import Control.Arrow import Data.Aeson -import Data.Aeson.Parser (jstring) -import Data.Attoparsec.ByteString (parseOnly) import Data.Either import Data.Function (on) import Data.Proxy @@ -164,11 +162,14 @@ spec = describe "Servant.API.ContentTypes" $ do describe "eitherDecodeLenient" $ do + -- aeson >= 0.9 decodes top-level strings +#if MIN_VERSION_aeson(0,9,0) it "parses top-level strings" $ do let toMaybe = either (const Nothing) Just -- The Left messages differ, so convert to Maybe property $ \x -> toMaybe (eitherDecodeLenient x) - `shouldBe` toMaybe (parseOnly jstring $ cs x) + `shouldBe` (decode x :: Maybe String) +#endif data SomeData = SomeData { record1 :: String, record2 :: Int }