Merge pull request #120 from haskell-servant/jkarni/travis_retry

travis retry - for a less lame CI story!
This commit is contained in:
Alp Mestanogullari 2015-06-12 15:35:07 +01:00
commit dfa30e890c
3 changed files with 33 additions and 4 deletions

View file

@ -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
}

View file

@ -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 () {

View file

@ -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 }