Merge remote-tracking branch 'origin/master' into header-yesod
Conflicts resolved in: yesod-core/ChangeLog.md yesod-core/yesod-core.cabal
This commit is contained in:
commit
7cfefdf3fa
33
.travis.yml
33
.travis.yml
@ -69,20 +69,12 @@ matrix:
|
||||
compiler: ": #stack default"
|
||||
addons: {apt: {packages: [libgmp-dev]}}
|
||||
|
||||
- env: BUILD=stack ARGS="--resolver lts-2"
|
||||
compiler: ": #stack 7.8.4"
|
||||
addons: {apt: {packages: [libgmp-dev]}}
|
||||
|
||||
- env: BUILD=stack ARGS="--resolver lts-3"
|
||||
compiler: ": #stack 7.10.2"
|
||||
addons: {apt: {packages: [libgmp-dev]}}
|
||||
|
||||
- env: BUILD=stack ARGS="--resolver lts-6"
|
||||
compiler: ": #stack 7.10.3"
|
||||
addons: {apt: {packages: [libgmp-dev]}}
|
||||
|
||||
- env: BUILD=stack ARGS="--resolver lts-7"
|
||||
compiler: ": #stack 8.0.1"
|
||||
- env: BUILD=stack ARGS="--resolver lts-8"
|
||||
compiler: ": #stack 8.0.2"
|
||||
addons: {apt: {packages: [libgmp-dev]}}
|
||||
|
||||
# Nightly builds are allowed to fail
|
||||
@ -95,21 +87,12 @@ matrix:
|
||||
compiler: ": #stack default osx"
|
||||
os: osx
|
||||
|
||||
# Travis includes an OS X which is incompatible with GHC 7.8.4
|
||||
#- env: BUILD=stack ARGS="--resolver lts-2"
|
||||
# compiler: ": #stack 7.8.4 osx"
|
||||
# os: osx
|
||||
|
||||
- env: BUILD=stack ARGS="--resolver lts-3"
|
||||
compiler: ": #stack 7.10.2 osx"
|
||||
os: osx
|
||||
|
||||
- env: BUILD=stack ARGS="--resolver lts-6"
|
||||
compiler: ": #stack 7.10.3 osx"
|
||||
os: osx
|
||||
|
||||
- env: BUILD=stack ARGS="--resolver lts-7"
|
||||
compiler: ": #stack 8.0.1 osx"
|
||||
- env: BUILD=stack ARGS="--resolver lts-8"
|
||||
compiler: ": #stack 8.0.2 osx"
|
||||
os: osx
|
||||
|
||||
- env: BUILD=stack ARGS="--resolver nightly"
|
||||
@ -119,6 +102,8 @@ matrix:
|
||||
allow_failures:
|
||||
- env: BUILD=cabal GHCVER=head CABALVER=head HAPPYVER=1.19.5 ALEXVER=3.1.7
|
||||
- env: BUILD=stack ARGS="--resolver nightly"
|
||||
- env: BUILD=cabal GHCVER=7.8.4 CABALVER=1.18 HAPPYVER=1.19.5 ALEXVER=3.1.7
|
||||
- env: BUILD=cabal GHCVER=7.10.3 CABALVER=1.22 HAPPYVER=1.19.5 ALEXVER=3.1.7
|
||||
|
||||
before_install:
|
||||
# Using compiler above sets CC to an invalid value, so unset it
|
||||
@ -171,9 +156,15 @@ script:
|
||||
# Build dependencies with -O0 as well
|
||||
echo "apply-ghc-options: everything" >> stack.yaml
|
||||
|
||||
# Avoid OOM for building Cabal
|
||||
stack --install-ghc --no-terminal $ARGS build Cabal --fast
|
||||
|
||||
# Use slightly less intensive options on OS X due to Travis timeouts
|
||||
stack --install-ghc --no-terminal $ARGS test --fast
|
||||
else
|
||||
# Avoid OOM for building Cabal
|
||||
stack --install-ghc --no-terminal $ARGS build Cabal --fast
|
||||
|
||||
stack --install-ghc --no-terminal $ARGS test --bench --no-run-benchmarks --haddock --no-haddock-deps --pedantic
|
||||
fi
|
||||
;;
|
||||
|
||||
33
stack.yaml
33
stack.yaml
@ -1,4 +1,4 @@
|
||||
resolver: lts-6.23
|
||||
resolver: lts-8.12
|
||||
packages:
|
||||
- ./yesod-core
|
||||
- ./yesod-static
|
||||
@ -13,34 +13,3 @@ packages:
|
||||
- ./yesod
|
||||
- ./yesod-eventsource
|
||||
- ./yesod-websockets
|
||||
|
||||
# Needed for LTS 2
|
||||
extra-deps:
|
||||
- wai-app-static-3.1.4.1
|
||||
- http-api-data-0.2
|
||||
- yaml-0.8.17
|
||||
- nonce-1.0.2
|
||||
- persistent-2.5
|
||||
- persistent-sqlite-2.5
|
||||
- cookie-0.4.2
|
||||
- cryptonite-0.23
|
||||
- foundation-0.0.9
|
||||
- memory-0.14.5
|
||||
- hfsevents-0.1.6
|
||||
- x509-1.6.5
|
||||
- x509-store-1.6.2
|
||||
- x509-system-1.6.4
|
||||
- x509-validation-1.6.5
|
||||
- tls-1.3.8
|
||||
- Win32-notify-0.3.0.1
|
||||
- asn1-parse-0.9.4
|
||||
- asn1-types-0.3.2
|
||||
- connection-0.2.8
|
||||
- socks-0.5.5
|
||||
|
||||
- conduit-extra-1.1.14
|
||||
- streaming-commons-0.1.16
|
||||
- typed-process-0.1.0.0
|
||||
- say-0.1.0.0
|
||||
- safe-exceptions-0.1.4.0
|
||||
- blaze-markup-0.7.1.0
|
||||
|
||||
@ -21,7 +21,7 @@ library
|
||||
cpp-options: -DGHC7
|
||||
else
|
||||
build-depends: base >= 4 && < 4.3
|
||||
build-depends: authenticate-oauth >= 1.5 && < 1.6
|
||||
build-depends: authenticate-oauth >= 1.5 && < 1.7
|
||||
, bytestring >= 0.9.1.4
|
||||
, yesod-core >= 1.4 && < 1.5
|
||||
, yesod-auth >= 1.4 && < 1.5
|
||||
|
||||
@ -74,7 +74,11 @@ import Control.Monad.IO.Class (MonadIO)
|
||||
import qualified Crypto.Nonce as Nonce
|
||||
import Data.Aeson ((.:?))
|
||||
import qualified Data.Aeson as A
|
||||
#if MIN_VERSION_aeson(1,0,0)
|
||||
import qualified Data.Aeson.Text as A
|
||||
#else
|
||||
import qualified Data.Aeson.Encode as A
|
||||
#endif
|
||||
import Data.Aeson.Parser (json')
|
||||
import Data.Aeson.Types (FromJSON (parseJSON), parseEither,
|
||||
parseMaybe, withObject, withText)
|
||||
|
||||
@ -2,6 +2,10 @@
|
||||
|
||||
* Add `replaceOrAddHeader` function in Yesod.Core.Handler module. [1416](https://github.com/yesodweb/yesod/issues/1416)
|
||||
|
||||
## 1.4.35.1
|
||||
|
||||
* TH fix for GHC 8.2
|
||||
|
||||
## 1.4.35
|
||||
|
||||
* Contexts can be included in generated TH instances. [1365](https://github.com/yesodweb/yesod/issues/1365)
|
||||
|
||||
@ -66,7 +66,8 @@ import Data.Conduit.Internal (ResumableSource (ResumableSource))
|
||||
import qualified Data.Conduit.Internal as CI
|
||||
|
||||
import qualified Data.Aeson as J
|
||||
#if MIN_VERSION_aeson(0, 7, 0)
|
||||
#if MIN_VERSION_aeson(1, 0, 0)
|
||||
#elif MIN_VERSION_aeson(0, 7, 0)
|
||||
import Data.Aeson.Encode (encodeToTextBuilder)
|
||||
#else
|
||||
import Data.Aeson.Encode (fromValue)
|
||||
@ -242,6 +243,11 @@ instance ToContent a => ToContent (DontFullyEvaluate a) where
|
||||
toContent (DontFullyEvaluate a) = ContentDontEvaluate $ toContent a
|
||||
|
||||
instance ToContent J.Value where
|
||||
#if MIN_VERSION_aeson(1, 0, 0)
|
||||
toContent = flip ContentBuilder Nothing
|
||||
. J.fromEncoding
|
||||
. J.toEncoding
|
||||
#else
|
||||
toContent = flip ContentBuilder Nothing
|
||||
. Blaze.fromLazyText
|
||||
. toLazyText
|
||||
@ -251,6 +257,8 @@ instance ToContent J.Value where
|
||||
. fromValue
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if MIN_VERSION_aeson(0, 11, 0)
|
||||
instance ToContent J.Encoding where
|
||||
toContent = flip ContentBuilder Nothing . J.fromEncoding
|
||||
|
||||
@ -76,7 +76,7 @@ import Database.Persist.Sql (PersistField, PersistFieldSql (..))
|
||||
#if MIN_VERSION_persistent(2,5,0)
|
||||
import Database.Persist (Entity (..), SqlType (SqlString), PersistRecordBackend, PersistQueryRead)
|
||||
#else
|
||||
import Database.Persist (Entity (..), SqlType (SqlString))
|
||||
import Database.Persist (Entity (..), SqlType (SqlString), PersistEntity, PersistQuery, PersistEntityBackend)
|
||||
#endif
|
||||
import Text.HTML.SanitizeXSS (sanitizeBalance)
|
||||
import Control.Monad (when, unless)
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
## 1.5.3.1
|
||||
|
||||
* Switch to cryptonite
|
||||
|
||||
## 1.5.3
|
||||
|
||||
* Add `staticFilesMap` function
|
||||
|
||||
@ -81,7 +81,7 @@ import Crypto.Hash (MD5, Digest)
|
||||
import Control.Monad.Catch (MonadThrow)
|
||||
import Control.Monad.Trans.State
|
||||
|
||||
import qualified Data.Byteable as Byteable
|
||||
import qualified Data.ByteArray as ByteArray
|
||||
import qualified Data.ByteString.Base64
|
||||
import qualified Data.ByteString.Char8 as S8
|
||||
import qualified Data.ByteString.Lazy as L
|
||||
@ -420,7 +420,7 @@ mkStaticFilesList' fp fs makeHash = do
|
||||
|
||||
base64md5File :: FilePath -> IO String
|
||||
base64md5File = fmap (base64 . encode) . hashFile
|
||||
where encode d = Byteable.toBytes (d :: Digest MD5)
|
||||
where encode d = ByteArray.convert (d :: Digest MD5)
|
||||
|
||||
base64md5 :: L.ByteString -> String
|
||||
base64md5 lbs =
|
||||
@ -428,7 +428,7 @@ base64md5 lbs =
|
||||
$ runIdentity
|
||||
$ sourceList (L.toChunks lbs) $$ sinkHash
|
||||
where
|
||||
encode d = Byteable.toBytes (d :: Digest MD5)
|
||||
encode d = ByteArray.convert (d :: Digest MD5)
|
||||
|
||||
base64 :: S.ByteString -> String
|
||||
base64 = map tr
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name: yesod-static
|
||||
version: 1.5.3
|
||||
version: 1.5.3.1
|
||||
license: MIT
|
||||
license-file: LICENSE
|
||||
author: Michael Snoyman <michael@snoyman.com>
|
||||
@ -44,8 +44,9 @@ library
|
||||
, unix-compat >= 0.2
|
||||
, conduit >= 0.5
|
||||
, conduit-extra
|
||||
, cryptohash-conduit >= 0.1
|
||||
, cryptohash >= 0.11
|
||||
, cryptonite-conduit >= 0.1
|
||||
, cryptonite >= 0.11
|
||||
, memory
|
||||
, data-default
|
||||
, mime-types >= 0.1
|
||||
, hjsmin
|
||||
@ -112,8 +113,9 @@ test-suite tests
|
||||
, http-types
|
||||
, unix-compat
|
||||
, conduit
|
||||
, cryptohash-conduit
|
||||
, cryptohash
|
||||
, cryptonite-conduit
|
||||
, cryptonite
|
||||
, memory
|
||||
, data-default
|
||||
, mime-types
|
||||
, hjsmin
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
## 1.5.8
|
||||
* Added implicit parameter HasCallStack to assertions.
|
||||
[#1421](https://github.com/yesodweb/yesod/pull/1421)
|
||||
|
||||
## 1.5.7
|
||||
|
||||
* Add clickOn.
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE ImplicitParams #-}
|
||||
{-# LANGUAGE ConstraintKinds #-}
|
||||
|
||||
{-|
|
||||
Yesod.Test is a pragmatic framework for testing web applications built
|
||||
@ -150,6 +152,16 @@ import Data.Time.Clock (getCurrentTime)
|
||||
import Control.Applicative ((<$>))
|
||||
import Text.Show.Pretty (ppShow)
|
||||
import Data.Monoid (mempty)
|
||||
#if MIN_VERSION_base(4,9,0)
|
||||
import GHC.Stack (HasCallStack)
|
||||
#elif MIN_VERSION_base(4,8,1)
|
||||
import GHC.Stack (CallStack)
|
||||
type HasCallStack = (?callStack :: CallStack)
|
||||
#else
|
||||
import GHC.Exts (Constraint)
|
||||
type HasCallStack = (() :: Constraint)
|
||||
#endif
|
||||
|
||||
|
||||
-- | The state used in a single test case defined using 'yit'
|
||||
--
|
||||
@ -330,7 +342,7 @@ htmlQuery = htmlQuery' yedResponse []
|
||||
-- In case they are not equal, error mesasge includes the two values.
|
||||
--
|
||||
-- @since 1.5.2
|
||||
assertEq :: (Eq a, Show a) => String -> a -> a -> YesodExample site ()
|
||||
assertEq :: (HasCallStack, Eq a, Show a) => String -> a -> a -> YesodExample site ()
|
||||
assertEq m a b =
|
||||
liftIO $ HUnit.assertBool msg (a == b)
|
||||
where msg = "Assertion: " ++ m ++ "\n" ++
|
||||
@ -342,24 +354,24 @@ assertEq m a b =
|
||||
-- In case they are equal, error mesasge includes the values.
|
||||
--
|
||||
-- @since 1.5.6
|
||||
assertNotEq :: (Eq a, Show a) => String -> a -> a -> YesodExample site ()
|
||||
assertNotEq :: (HasCallStack, Eq a, Show a) => String -> a -> a -> YesodExample site ()
|
||||
assertNotEq m a b =
|
||||
liftIO $ HUnit.assertBool msg (a /= b)
|
||||
where msg = "Assertion: " ++ m ++ "\n" ++
|
||||
"Both arguments: " ++ ppShow a ++ "\n"
|
||||
|
||||
{-# DEPRECATED assertEqual "Use assertEq instead" #-}
|
||||
assertEqual :: (Eq a) => String -> a -> a -> YesodExample site ()
|
||||
assertEqual :: (HasCallStack, Eq a) => String -> a -> a -> YesodExample site ()
|
||||
assertEqual = assertEqualNoShow
|
||||
|
||||
-- | Asserts that the two given values are equal.
|
||||
--
|
||||
-- @since 1.5.2
|
||||
assertEqualNoShow :: (Eq a) => String -> a -> a -> YesodExample site ()
|
||||
assertEqualNoShow :: (HasCallStack, Eq a) => String -> a -> a -> YesodExample site ()
|
||||
assertEqualNoShow msg a b = liftIO $ HUnit.assertBool msg (a == b)
|
||||
|
||||
-- | Assert the last response status is as expected.
|
||||
statusIs :: Int -> YesodExample site ()
|
||||
statusIs :: HasCallStack => Int -> YesodExample site ()
|
||||
statusIs number = withResponse $ \ SResponse { simpleStatus = s } ->
|
||||
liftIO $ flip HUnit.assertBool (H.statusCode s == number) $ concat
|
||||
[ "Expected status was ", show number
|
||||
@ -367,7 +379,7 @@ statusIs number = withResponse $ \ SResponse { simpleStatus = s } ->
|
||||
]
|
||||
|
||||
-- | Assert the given header key/value pair was returned.
|
||||
assertHeader :: CI BS8.ByteString -> BS8.ByteString -> YesodExample site ()
|
||||
assertHeader :: HasCallStack => CI BS8.ByteString -> BS8.ByteString -> YesodExample site ()
|
||||
assertHeader header value = withResponse $ \ SResponse { simpleHeaders = h } ->
|
||||
case lookup header h of
|
||||
Nothing -> failure $ T.pack $ concat
|
||||
@ -387,7 +399,7 @@ assertHeader header value = withResponse $ \ SResponse { simpleHeaders = h } ->
|
||||
]
|
||||
|
||||
-- | Assert the given header was not included in the response.
|
||||
assertNoHeader :: CI BS8.ByteString -> YesodExample site ()
|
||||
assertNoHeader :: HasCallStack => CI BS8.ByteString -> YesodExample site ()
|
||||
assertNoHeader header = withResponse $ \ SResponse { simpleHeaders = h } ->
|
||||
case lookup header h of
|
||||
Nothing -> return ()
|
||||
@ -400,14 +412,14 @@ assertNoHeader header = withResponse $ \ SResponse { simpleHeaders = h } ->
|
||||
|
||||
-- | Assert the last response is exactly equal to the given text. This is
|
||||
-- useful for testing API responses.
|
||||
bodyEquals :: String -> YesodExample site ()
|
||||
bodyEquals :: HasCallStack => String -> YesodExample site ()
|
||||
bodyEquals text = withResponse $ \ res ->
|
||||
liftIO $ HUnit.assertBool ("Expected body to equal " ++ text) $
|
||||
(simpleBody res) == encodeUtf8 (TL.pack text)
|
||||
|
||||
-- | Assert the last response has the given text. The check is performed using the response
|
||||
-- body in full text form.
|
||||
bodyContains :: String -> YesodExample site ()
|
||||
bodyContains :: HasCallStack => String -> YesodExample site ()
|
||||
bodyContains text = withResponse $ \ res ->
|
||||
liftIO $ HUnit.assertBool ("Expected body to contain " ++ text) $
|
||||
(simpleBody res) `contains` text
|
||||
@ -415,7 +427,7 @@ bodyContains text = withResponse $ \ res ->
|
||||
-- | Assert the last response doesn't have the given text. The check is performed using the response
|
||||
-- body in full text form.
|
||||
-- @since 1.5.3
|
||||
bodyNotContains :: String -> YesodExample site ()
|
||||
bodyNotContains :: HasCallStack => String -> YesodExample site ()
|
||||
bodyNotContains text = withResponse $ \ res ->
|
||||
liftIO $ HUnit.assertBool ("Expected body not to contain " ++ text) $
|
||||
not $ contains (simpleBody res) text
|
||||
@ -425,7 +437,7 @@ contains a b = DL.isInfixOf b (TL.unpack $ decodeUtf8 a)
|
||||
|
||||
-- | Queries the HTML using a CSS selector, and all matched elements must contain
|
||||
-- the given string.
|
||||
htmlAllContain :: Query -> String -> YesodExample site ()
|
||||
htmlAllContain :: HasCallStack => Query -> String -> YesodExample site ()
|
||||
htmlAllContain query search = do
|
||||
matches <- htmlQuery query
|
||||
case matches of
|
||||
@ -437,7 +449,7 @@ htmlAllContain query search = do
|
||||
-- element contains the given string.
|
||||
--
|
||||
-- Since 0.3.5
|
||||
htmlAnyContain :: Query -> String -> YesodExample site ()
|
||||
htmlAnyContain :: HasCallStack => Query -> String -> YesodExample site ()
|
||||
htmlAnyContain query search = do
|
||||
matches <- htmlQuery query
|
||||
case matches of
|
||||
@ -450,7 +462,7 @@ htmlAnyContain query search = do
|
||||
-- inverse of htmlAnyContains).
|
||||
--
|
||||
-- Since 1.2.2
|
||||
htmlNoneContain :: Query -> String -> YesodExample site ()
|
||||
htmlNoneContain :: HasCallStack => Query -> String -> YesodExample site ()
|
||||
htmlNoneContain query search = do
|
||||
matches <- htmlQuery query
|
||||
case DL.filter (DL.isInfixOf search) (map (TL.unpack . decodeUtf8) matches) of
|
||||
@ -460,7 +472,7 @@ htmlNoneContain query search = do
|
||||
|
||||
-- | Performs a CSS query on the last response and asserts the matched elements
|
||||
-- are as many as expected.
|
||||
htmlCount :: Query -> Int -> YesodExample site ()
|
||||
htmlCount :: HasCallStack => Query -> Int -> YesodExample site ()
|
||||
htmlCount query count = do
|
||||
matches <- fmap DL.length $ htmlQuery query
|
||||
liftIO $ flip HUnit.assertBool (matches == count)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name: yesod-test
|
||||
version: 1.5.7
|
||||
version: 1.5.8
|
||||
license: MIT
|
||||
license-file: LICENSE
|
||||
author: Nubis <nubis@woobiz.com.ar>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user