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:
Sibi Prabakaran 2017-07-28 17:01:03 +05:30
commit 7cfefdf3fa
No known key found for this signature in database
GPG Key ID: D19E3E0EBB557613
13 changed files with 77 additions and 79 deletions

View File

@ -69,20 +69,12 @@ matrix:
compiler: ": #stack default" compiler: ": #stack default"
addons: {apt: {packages: [libgmp-dev]}} 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" - env: BUILD=stack ARGS="--resolver lts-6"
compiler: ": #stack 7.10.3" compiler: ": #stack 7.10.3"
addons: {apt: {packages: [libgmp-dev]}} addons: {apt: {packages: [libgmp-dev]}}
- env: BUILD=stack ARGS="--resolver lts-7" - env: BUILD=stack ARGS="--resolver lts-8"
compiler: ": #stack 8.0.1" compiler: ": #stack 8.0.2"
addons: {apt: {packages: [libgmp-dev]}} addons: {apt: {packages: [libgmp-dev]}}
# Nightly builds are allowed to fail # Nightly builds are allowed to fail
@ -95,21 +87,12 @@ matrix:
compiler: ": #stack default osx" compiler: ": #stack default osx"
os: 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" - env: BUILD=stack ARGS="--resolver lts-6"
compiler: ": #stack 7.10.3 osx" compiler: ": #stack 7.10.3 osx"
os: osx os: osx
- env: BUILD=stack ARGS="--resolver lts-7" - env: BUILD=stack ARGS="--resolver lts-8"
compiler: ": #stack 8.0.1 osx" compiler: ": #stack 8.0.2 osx"
os: osx os: osx
- env: BUILD=stack ARGS="--resolver nightly" - env: BUILD=stack ARGS="--resolver nightly"
@ -119,6 +102,8 @@ matrix:
allow_failures: allow_failures:
- env: BUILD=cabal GHCVER=head CABALVER=head HAPPYVER=1.19.5 ALEXVER=3.1.7 - env: BUILD=cabal GHCVER=head CABALVER=head HAPPYVER=1.19.5 ALEXVER=3.1.7
- env: BUILD=stack ARGS="--resolver nightly" - 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: before_install:
# Using compiler above sets CC to an invalid value, so unset it # Using compiler above sets CC to an invalid value, so unset it
@ -171,9 +156,15 @@ script:
# Build dependencies with -O0 as well # Build dependencies with -O0 as well
echo "apply-ghc-options: everything" >> stack.yaml 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 # Use slightly less intensive options on OS X due to Travis timeouts
stack --install-ghc --no-terminal $ARGS test --fast stack --install-ghc --no-terminal $ARGS test --fast
else 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 stack --install-ghc --no-terminal $ARGS test --bench --no-run-benchmarks --haddock --no-haddock-deps --pedantic
fi fi
;; ;;

View File

@ -1,4 +1,4 @@
resolver: lts-6.23 resolver: lts-8.12
packages: packages:
- ./yesod-core - ./yesod-core
- ./yesod-static - ./yesod-static
@ -13,34 +13,3 @@ packages:
- ./yesod - ./yesod
- ./yesod-eventsource - ./yesod-eventsource
- ./yesod-websockets - ./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

View File

@ -21,7 +21,7 @@ library
cpp-options: -DGHC7 cpp-options: -DGHC7
else else
build-depends: base >= 4 && < 4.3 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 , bytestring >= 0.9.1.4
, yesod-core >= 1.4 && < 1.5 , yesod-core >= 1.4 && < 1.5
, yesod-auth >= 1.4 && < 1.5 , yesod-auth >= 1.4 && < 1.5

View File

@ -74,7 +74,11 @@ import Control.Monad.IO.Class (MonadIO)
import qualified Crypto.Nonce as Nonce import qualified Crypto.Nonce as Nonce
import Data.Aeson ((.:?)) import Data.Aeson ((.:?))
import qualified Data.Aeson as A 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 import qualified Data.Aeson.Encode as A
#endif
import Data.Aeson.Parser (json') import Data.Aeson.Parser (json')
import Data.Aeson.Types (FromJSON (parseJSON), parseEither, import Data.Aeson.Types (FromJSON (parseJSON), parseEither,
parseMaybe, withObject, withText) parseMaybe, withObject, withText)

View File

@ -2,6 +2,10 @@
* Add `replaceOrAddHeader` function in Yesod.Core.Handler module. [1416](https://github.com/yesodweb/yesod/issues/1416) * 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 ## 1.4.35
* Contexts can be included in generated TH instances. [1365](https://github.com/yesodweb/yesod/issues/1365) * Contexts can be included in generated TH instances. [1365](https://github.com/yesodweb/yesod/issues/1365)

View File

@ -66,7 +66,8 @@ import Data.Conduit.Internal (ResumableSource (ResumableSource))
import qualified Data.Conduit.Internal as CI import qualified Data.Conduit.Internal as CI
import qualified Data.Aeson as J 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) import Data.Aeson.Encode (encodeToTextBuilder)
#else #else
import Data.Aeson.Encode (fromValue) import Data.Aeson.Encode (fromValue)
@ -242,6 +243,11 @@ instance ToContent a => ToContent (DontFullyEvaluate a) where
toContent (DontFullyEvaluate a) = ContentDontEvaluate $ toContent a toContent (DontFullyEvaluate a) = ContentDontEvaluate $ toContent a
instance ToContent J.Value where 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 toContent = flip ContentBuilder Nothing
. Blaze.fromLazyText . Blaze.fromLazyText
. toLazyText . toLazyText
@ -251,6 +257,8 @@ instance ToContent J.Value where
. fromValue . fromValue
#endif #endif
#endif
#if MIN_VERSION_aeson(0, 11, 0) #if MIN_VERSION_aeson(0, 11, 0)
instance ToContent J.Encoding where instance ToContent J.Encoding where
toContent = flip ContentBuilder Nothing . J.fromEncoding toContent = flip ContentBuilder Nothing . J.fromEncoding

View File

@ -76,7 +76,7 @@ import Database.Persist.Sql (PersistField, PersistFieldSql (..))
#if MIN_VERSION_persistent(2,5,0) #if MIN_VERSION_persistent(2,5,0)
import Database.Persist (Entity (..), SqlType (SqlString), PersistRecordBackend, PersistQueryRead) import Database.Persist (Entity (..), SqlType (SqlString), PersistRecordBackend, PersistQueryRead)
#else #else
import Database.Persist (Entity (..), SqlType (SqlString)) import Database.Persist (Entity (..), SqlType (SqlString), PersistEntity, PersistQuery, PersistEntityBackend)
#endif #endif
import Text.HTML.SanitizeXSS (sanitizeBalance) import Text.HTML.SanitizeXSS (sanitizeBalance)
import Control.Monad (when, unless) import Control.Monad (when, unless)

View File

@ -1,3 +1,7 @@
## 1.5.3.1
* Switch to cryptonite
## 1.5.3 ## 1.5.3
* Add `staticFilesMap` function * Add `staticFilesMap` function

View File

@ -81,7 +81,7 @@ import Crypto.Hash (MD5, Digest)
import Control.Monad.Catch (MonadThrow) import Control.Monad.Catch (MonadThrow)
import Control.Monad.Trans.State 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.Base64
import qualified Data.ByteString.Char8 as S8 import qualified Data.ByteString.Char8 as S8
import qualified Data.ByteString.Lazy as L import qualified Data.ByteString.Lazy as L
@ -420,7 +420,7 @@ mkStaticFilesList' fp fs makeHash = do
base64md5File :: FilePath -> IO String base64md5File :: FilePath -> IO String
base64md5File = fmap (base64 . encode) . hashFile 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 :: L.ByteString -> String
base64md5 lbs = base64md5 lbs =
@ -428,7 +428,7 @@ base64md5 lbs =
$ runIdentity $ runIdentity
$ sourceList (L.toChunks lbs) $$ sinkHash $ sourceList (L.toChunks lbs) $$ sinkHash
where where
encode d = Byteable.toBytes (d :: Digest MD5) encode d = ByteArray.convert (d :: Digest MD5)
base64 :: S.ByteString -> String base64 :: S.ByteString -> String
base64 = map tr base64 = map tr

View File

@ -1,5 +1,5 @@
name: yesod-static name: yesod-static
version: 1.5.3 version: 1.5.3.1
license: MIT license: MIT
license-file: LICENSE license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com> author: Michael Snoyman <michael@snoyman.com>
@ -44,8 +44,9 @@ library
, unix-compat >= 0.2 , unix-compat >= 0.2
, conduit >= 0.5 , conduit >= 0.5
, conduit-extra , conduit-extra
, cryptohash-conduit >= 0.1 , cryptonite-conduit >= 0.1
, cryptohash >= 0.11 , cryptonite >= 0.11
, memory
, data-default , data-default
, mime-types >= 0.1 , mime-types >= 0.1
, hjsmin , hjsmin
@ -112,8 +113,9 @@ test-suite tests
, http-types , http-types
, unix-compat , unix-compat
, conduit , conduit
, cryptohash-conduit , cryptonite-conduit
, cryptohash , cryptonite
, memory
, data-default , data-default
, mime-types , mime-types
, hjsmin , hjsmin

View File

@ -1,3 +1,7 @@
## 1.5.8
* Added implicit parameter HasCallStack to assertions.
[#1421](https://github.com/yesodweb/yesod/pull/1421)
## 1.5.7 ## 1.5.7
* Add clickOn. * Add clickOn.

View File

@ -4,6 +4,8 @@
{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ImplicitParams #-}
{-# LANGUAGE ConstraintKinds #-}
{-| {-|
Yesod.Test is a pragmatic framework for testing web applications built Yesod.Test is a pragmatic framework for testing web applications built
@ -150,6 +152,16 @@ import Data.Time.Clock (getCurrentTime)
import Control.Applicative ((<$>)) import Control.Applicative ((<$>))
import Text.Show.Pretty (ppShow) import Text.Show.Pretty (ppShow)
import Data.Monoid (mempty) 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' -- | 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. -- In case they are not equal, error mesasge includes the two values.
-- --
-- @since 1.5.2 -- @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 = assertEq m a b =
liftIO $ HUnit.assertBool msg (a == b) liftIO $ HUnit.assertBool msg (a == b)
where msg = "Assertion: " ++ m ++ "\n" ++ where msg = "Assertion: " ++ m ++ "\n" ++
@ -342,24 +354,24 @@ assertEq m a b =
-- In case they are equal, error mesasge includes the values. -- In case they are equal, error mesasge includes the values.
-- --
-- @since 1.5.6 -- @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 = assertNotEq m a b =
liftIO $ HUnit.assertBool msg (a /= b) liftIO $ HUnit.assertBool msg (a /= b)
where msg = "Assertion: " ++ m ++ "\n" ++ where msg = "Assertion: " ++ m ++ "\n" ++
"Both arguments: " ++ ppShow a ++ "\n" "Both arguments: " ++ ppShow a ++ "\n"
{-# DEPRECATED assertEqual "Use assertEq instead" #-} {-# DEPRECATED assertEqual "Use assertEq instead" #-}
assertEqual :: (Eq a) => String -> a -> a -> YesodExample site () assertEqual :: (HasCallStack, Eq a) => String -> a -> a -> YesodExample site ()
assertEqual = assertEqualNoShow assertEqual = assertEqualNoShow
-- | Asserts that the two given values are equal. -- | Asserts that the two given values are equal.
-- --
-- @since 1.5.2 -- @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) assertEqualNoShow msg a b = liftIO $ HUnit.assertBool msg (a == b)
-- | Assert the last response status is as expected. -- | Assert the last response status is as expected.
statusIs :: Int -> YesodExample site () statusIs :: HasCallStack => Int -> YesodExample site ()
statusIs number = withResponse $ \ SResponse { simpleStatus = s } -> statusIs number = withResponse $ \ SResponse { simpleStatus = s } ->
liftIO $ flip HUnit.assertBool (H.statusCode s == number) $ concat liftIO $ flip HUnit.assertBool (H.statusCode s == number) $ concat
[ "Expected status was ", show number [ "Expected status was ", show number
@ -367,7 +379,7 @@ statusIs number = withResponse $ \ SResponse { simpleStatus = s } ->
] ]
-- | Assert the given header key/value pair was returned. -- | 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 } -> assertHeader header value = withResponse $ \ SResponse { simpleHeaders = h } ->
case lookup header h of case lookup header h of
Nothing -> failure $ T.pack $ concat 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. -- | 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 } -> assertNoHeader header = withResponse $ \ SResponse { simpleHeaders = h } ->
case lookup header h of case lookup header h of
Nothing -> return () 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 -- | Assert the last response is exactly equal to the given text. This is
-- useful for testing API responses. -- useful for testing API responses.
bodyEquals :: String -> YesodExample site () bodyEquals :: HasCallStack => String -> YesodExample site ()
bodyEquals text = withResponse $ \ res -> bodyEquals text = withResponse $ \ res ->
liftIO $ HUnit.assertBool ("Expected body to equal " ++ text) $ liftIO $ HUnit.assertBool ("Expected body to equal " ++ text) $
(simpleBody res) == encodeUtf8 (TL.pack text) (simpleBody res) == encodeUtf8 (TL.pack text)
-- | Assert the last response has the given text. The check is performed using the response -- | Assert the last response has the given text. The check is performed using the response
-- body in full text form. -- body in full text form.
bodyContains :: String -> YesodExample site () bodyContains :: HasCallStack => String -> YesodExample site ()
bodyContains text = withResponse $ \ res -> bodyContains text = withResponse $ \ res ->
liftIO $ HUnit.assertBool ("Expected body to contain " ++ text) $ liftIO $ HUnit.assertBool ("Expected body to contain " ++ text) $
(simpleBody res) `contains` 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 -- | Assert the last response doesn't have the given text. The check is performed using the response
-- body in full text form. -- body in full text form.
-- @since 1.5.3 -- @since 1.5.3
bodyNotContains :: String -> YesodExample site () bodyNotContains :: HasCallStack => String -> YesodExample site ()
bodyNotContains text = withResponse $ \ res -> bodyNotContains text = withResponse $ \ res ->
liftIO $ HUnit.assertBool ("Expected body not to contain " ++ text) $ liftIO $ HUnit.assertBool ("Expected body not to contain " ++ text) $
not $ contains (simpleBody res) 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 -- | Queries the HTML using a CSS selector, and all matched elements must contain
-- the given string. -- the given string.
htmlAllContain :: Query -> String -> YesodExample site () htmlAllContain :: HasCallStack => Query -> String -> YesodExample site ()
htmlAllContain query search = do htmlAllContain query search = do
matches <- htmlQuery query matches <- htmlQuery query
case matches of case matches of
@ -437,7 +449,7 @@ htmlAllContain query search = do
-- element contains the given string. -- element contains the given string.
-- --
-- Since 0.3.5 -- Since 0.3.5
htmlAnyContain :: Query -> String -> YesodExample site () htmlAnyContain :: HasCallStack => Query -> String -> YesodExample site ()
htmlAnyContain query search = do htmlAnyContain query search = do
matches <- htmlQuery query matches <- htmlQuery query
case matches of case matches of
@ -450,7 +462,7 @@ htmlAnyContain query search = do
-- inverse of htmlAnyContains). -- inverse of htmlAnyContains).
-- --
-- Since 1.2.2 -- Since 1.2.2
htmlNoneContain :: Query -> String -> YesodExample site () htmlNoneContain :: HasCallStack => Query -> String -> YesodExample site ()
htmlNoneContain query search = do htmlNoneContain query search = do
matches <- htmlQuery query matches <- htmlQuery query
case DL.filter (DL.isInfixOf search) (map (TL.unpack . decodeUtf8) matches) of 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 -- | Performs a CSS query on the last response and asserts the matched elements
-- are as many as expected. -- are as many as expected.
htmlCount :: Query -> Int -> YesodExample site () htmlCount :: HasCallStack => Query -> Int -> YesodExample site ()
htmlCount query count = do htmlCount query count = do
matches <- fmap DL.length $ htmlQuery query matches <- fmap DL.length $ htmlQuery query
liftIO $ flip HUnit.assertBool (matches == count) liftIO $ flip HUnit.assertBool (matches == count)

View File

@ -1,5 +1,5 @@
name: yesod-test name: yesod-test
version: 1.5.7 version: 1.5.8
license: MIT license: MIT
license-file: LICENSE license-file: LICENSE
author: Nubis <nubis@woobiz.com.ar> author: Nubis <nubis@woobiz.com.ar>