api-tools 0.8.0.1 → 0.8.0.2
raw patch · 6 files changed
+77/−97 lines, 6 filesdep +semigroupsdep −binarydep ~Cabaldep ~QuickCheckdep ~aeson
Dependencies added: semigroups
Dependencies removed: binary
Dependency ranges changed: Cabal, QuickCheck, aeson, aeson-pretty, base, base64-bytestring, bytestring, cborg, containers, deepseq, lens, safecopy, serialise, tasty, tasty-quickcheck, template-haskell, text, time, unordered-containers, vector
Files
- api-tools.cabal +44/−78
- changelog +3/−0
- src/Data/API/JSON.hs +1/−1
- src/Data/API/TH/Compat.hs +6/−2
- src/Data/API/Tools/Combinators.hs +7/−0
- tests/Data/API/Test/Migration.hs +16/−16
api-tools.cabal view
@@ -1,5 +1,5 @@ Name: api-tools-Version: 0.8.0.1+Version: 0.8.0.2 Synopsis: DSL for generating API boilerplate and docs Description: api-tools provides a compact DSL for describing an API. It uses Template Haskell to generate the@@ -12,11 +12,12 @@ License-file: LICENSE Author: Chris Dornan <chrisd@irisconnect.co.uk> and Adam Gundry <adam@well-typed.com> Maintainer: Chris Dornan <chrisd@irisconnect.co.uk> and Adam Gundry <adam@well-typed.com>-Copyright: (c) Iris Connect 2013-2014+Copyright: (c) Iris Connect 2013-2018 Category: Network, Web, Cloud, Distributed Computing Build-type: Simple Extra-source-files: changelog Cabal-version: >=1.10+Tested-with: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.2 Source-Repository head Type: git@@ -25,7 +26,7 @@ Source-Repository this Type: git Location: git://github.com/iconnect/api-tools.git- Tag: 0.8.0.0+ Tag: 0.8.0.2 flag time15 default: True@@ -77,40 +78,43 @@ Data.API.TH.Compat Build-depends:- Cabal >= 1.4 && < 2 ,- QuickCheck >= 2.5.1 && < 2.10 ,- aeson >= 0.10 && < 1.3 ,+ Cabal >= 1.4 && < 2.5 ,+ QuickCheck >= 2.5.1 && < 2.13 ,+ aeson >= 0.10 && < 1.5 , aeson-pretty >= 0.1 && < 0.9 , array >= 0.4 && < 0.6 , attoparsec >= 0.10.4 && < 0.14 , base >= 4 && < 5 , base16-bytestring >= 0.1 && < 0.2 , base64-bytestring >= 1.0 && < 1.1 ,- binary, bytestring >= 0.9 && < 0.11 , case-insensitive >= 1.0 && < 1.3 ,- cborg >= 0.1.1.0 && < 0.2 ,- containers >= 0.5 && < 0.6 ,+ cborg >= 0.1.1.0 && < 0.3 ,+ containers >= 0.5 && < 0.7 , deepseq >= 1.1 && < 1.5 ,- lens >= 3.8.7 && < 4.16 ,+ lens >= 3.8.7 && < 4.18 , regex-compat-tdfa >= 0.95.1 && < 0.96 , safe >= 0.3.3 && < 0.4 , safecopy >= 0.8.1 && < 0.10 , scientific >= 0.3 && < 0.4 ,- serialise >= 0.1.0.0 && < 0.2 ,- template-haskell >= 2.7 && < 2.12 ,+ serialise >= 0.1.0.0 && < 0.3 ,+ template-haskell >= 2.7 && < 2.15 , text >= 0.11.3 && < 1.3 , unordered-containers >= 0.2.3.0 && < 0.3 ,- vector >= 0.10.0.1 && < 0.12+ vector >= 0.10.0.1 && < 0.13 if flag(time15) Build-depends:- time >= 1.5.0 && < 1.7+ time >= 1.5.0 && < 1.10 else Build-depends: old-locale >= 1 && < 1.1, time >= 1.1.4 && < 1.5 + if !impl(ghc >= 8.0)+ -- Needed for Data.Semigroup before it was in base+ build-depends: semigroups == 0.18.*+ Build-tools: alex, happy@@ -129,24 +133,10 @@ Build-depends: api-tools,- QuickCheck >= 2.5.1 && < 2.10 ,- aeson ,- aeson-pretty >= 0.1 && < 0.9 ,- array >= 0.4 && < 0.6 ,- attoparsec >= 0.10.4 && < 0.14 ,- base >= 4 && < 5 ,- base64-bytestring >= 1.0 && < 1.1 ,- bytestring >= 0.9 && < 0.11 ,- case-insensitive >= 1.0 && < 1.3 ,- containers >= 0.5 && < 0.6 ,- lens >= 3.8.7 && < 4.16 ,- regex-compat-tdfa >= 0.95.1 && < 0.96 ,- safe >= 0.3.3 && < 0.4 ,- safecopy >= 0.8.1 && < 0.10 ,- template-haskell >= 2.7 && < 2.12 ,- text >= 0.11.3 && < 1.3 ,- unordered-containers >= 0.2.3.0 && < 0.3 ,- vector >= 0.10.0.1 && < 0.12+ aeson,+ aeson-pretty,+ base,+ bytestring GHC-Options: -main-is Data.API.MigrationTool@@ -163,28 +153,11 @@ Build-depends: api-tools,- QuickCheck >= 2.5.1 && < 2.10 ,- aeson ,- aeson-pretty >= 0.1 && < 0.9 ,- array >= 0.4 && < 0.6 ,- attoparsec >= 0.10.4 && < 0.14 ,- base >= 4 && < 5 ,- base64-bytestring >= 1.0 && < 1.1 ,- bytestring >= 0.9 && < 0.11 ,- case-insensitive >= 1.0 && < 1.3 ,- cborg >= 0.1.1.0 && < 0.2 ,- containers >= 0.5 && < 0.6 ,- deepseq >= 1.1 && < 1.5 ,- lens >= 3.8.7 && < 4.16 ,- regex-compat-tdfa >= 0.95.1 && < 0.96 ,- safe >= 0.3.3 && < 0.4 ,- safecopy >= 0.8.1 && < 0.10 ,- serialise >= 0.1.0.0 && < 0.2 ,- template-haskell >= 2.7 && < 2.12 ,- text >= 0.11.3 && < 1.3 ,- unordered-containers >= 0.2.3.0 && < 0.3 ,- vector >= 0.10.0.1 && < 0.12,- time+ QuickCheck,+ aeson,+ base,+ deepseq,+ serialise GHC-Options: -main-is Data.API.PerfTest@@ -211,31 +184,24 @@ Build-depends: api-tools,- Cabal >= 1.4 && < 2 ,- QuickCheck >= 2.5.1 && < 2.10 ,- aeson ,- aeson-pretty >= 0.1 && < 0.9 ,- array >= 0.4 && < 0.6 ,- attoparsec >= 0.10.4 && < 0.14 ,- base >= 4 && < 5 ,- base64-bytestring >= 1.0 && < 1.1 ,- bytestring >= 0.9 && < 0.11 ,- case-insensitive >= 1.0 && < 1.3 ,- cborg >= 0.1.1.0 && < 0.2 ,- containers >= 0.5 && < 0.6 ,- lens >= 3.8.7 && < 4.16 ,- regex-compat-tdfa >= 0.95.1 && < 0.96 ,- safe >= 0.3.3 && < 0.4 ,- safecopy >= 0.8.1 && < 0.10 ,- serialise >= 0.1.0.0 && < 0.2 ,- tasty >= 0.10.1 && < 0.12 ,- tasty-hunit >= 0.2 && < 10.0 ,- tasty-quickcheck >= 0.3 && < 0.9 ,+ Cabal,+ QuickCheck,+ aeson,+ aeson-pretty,+ base,+ base64-bytestring,+ bytestring,+ cborg,+ containers,+ safecopy,+ serialise,+ tasty >= 0.10.1 && < 1.2 ,+ tasty-hunit >= 0.2 && < 10.0,+ tasty-quickcheck >= 0.3 && < 0.11, time,- template-haskell >= 2.7 && < 2.12 ,- text >= 0.11.3 && < 1.3 ,- unordered-containers >= 0.2.3.0 && < 0.3 ,- vector >= 0.10.0.1 && < 0.12+ template-haskell,+ text,+ unordered-containers GHC-Options: -main-is Data.API.Test.Main
changelog view
@@ -1,5 +1,8 @@ -*-change-log-*- +0.8.0.2 Adam Gundry <adam@well-typed.com> November 2018+ * Relax dependency bounds and support building on GHC 8.4.x and 8.6.x+ 0.8.0.1 Adam Gundry <adam@well-typed.com> October 2017 * Silently truncate floating point numbers to integers
src/Data/API/JSON.hs view
@@ -82,7 +82,7 @@ import Data.Traversable import qualified Data.Vector as V import Data.Version-import Distribution.Text+import Distribution.Text (simpleParse) import Text.Regex import Prelude
src/Data/API/TH/Compat.hs view
@@ -5,7 +5,9 @@ mkDataD :: Cxt -> Name -> [TyVarBndr] -> [Con] -> [Name] -> Dec mkDataD cxt1 name tyVarBndrs cons drvs =-#if MIN_VERSION_template_haskell(2,11,0)+#if MIN_VERSION_template_haskell(2,12,0)+ DataD cxt1 name tyVarBndrs Nothing cons [DerivClause Nothing (map ConT drvs)]+#elif MIN_VERSION_template_haskell(2,11,0) DataD cxt1 name tyVarBndrs Nothing cons (map ConT drvs) #else DataD cxt1 name tyVarBndrs cons drvs@@ -21,7 +23,9 @@ mkNewtypeD :: Cxt -> Name -> [TyVarBndr] -> Con -> [Name] -> Dec mkNewtypeD cxt1 name tyVarBndrs cons drvs =-#if MIN_VERSION_template_haskell(2,11,0)+#if MIN_VERSION_template_haskell(2,12,0)+ NewtypeD cxt1 name tyVarBndrs Nothing cons [DerivClause Nothing (map ConT drvs)]+#elif MIN_VERSION_template_haskell(2,11,0) NewtypeD cxt1 name tyVarBndrs Nothing cons (map ConT drvs) #else NewtypeD cxt1 name tyVarBndrs cons drvs
src/Data/API/Tools/Combinators.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE TemplateHaskell #-} module Data.API.Tools.Combinators@@ -27,6 +28,7 @@ import Control.Applicative import Data.Monoid+import Data.Semigroup as Sem import Language.Haskell.TH import Prelude @@ -61,9 +63,14 @@ type APITool = Tool API type APINodeTool = Tool APINode +instance Sem.Semigroup (Tool a) where+ Tool t1 <> Tool t2 = Tool $ \ ts x -> (++) <$> t1 ts x <*> t2 ts x+ instance Monoid (Tool a) where mempty = Tool $ \ _ _ -> return []+#if !(MIN_VERSION_base(4,11,0)) Tool t1 `mappend` Tool t2 = Tool $ \ ts x -> (++) <$> t1 ts x <*> t2 ts x+#endif -- | Construct a tool that does not depend on any settings simpleTool :: (a -> Q [Dec]) -> Tool a
tests/Data/API/Test/Migration.hs view
@@ -29,7 +29,7 @@ import qualified Data.Text.Encoding as TE import Data.Version import Test.Tasty as Test-import Test.Tasty.HUnit+import qualified Test.Tasty.HUnit as HUnit import qualified Test.Tasty.QuickCheck as QC import Test.QuickCheck.Property as P @@ -130,44 +130,44 @@ testFieldMigration' -assertMatchesAPI :: String -> API -> JS.Value -> Assertion+assertMatchesAPI :: String -> API -> JS.Value -> HUnit.Assertion assertMatchesAPI x a v = case dataMatchesAPI root_ a v of Right () -> return ()- Left err -> assertFailure (x ++ ": " ++ prettyValueErrorPosition err)+ Left err -> HUnit.assertFailure (x ++ ": " ++ prettyValueErrorPosition err) -basicMigrationTest :: Assertion+basicMigrationTest :: HUnit.Assertion basicMigrationTest = do assertMatchesAPI "Start data does not match start API" startSchema startData assertMatchesAPI "End data does not match end API" endSchema endData case migrateDataDump (startSchema, startVersion) (endSchema, DevVersion) changelog testMigration root_ CheckAll startData of Right (v, []) | endData == v -> return ()- | otherwise -> assertFailure $ "expected:\n"+ | otherwise -> HUnit.assertFailure $ "expected:\n" ++ BL.unpack (JS.encodePretty endData) ++ "\nbut got:\n" ++ BL.unpack (JS.encodePretty v)- Right (_, ws) -> assertFailure $ "Unexpcted warnings: " ++ show ws- Left err -> assertFailure (prettyMigrateFailure err)+ Right (_, ws) -> HUnit.assertFailure $ "Unexpcted warnings: " ++ show ws+ Left err -> HUnit.assertFailure (prettyMigrateFailure err) applyFailureTest :: (Version, Version, ApplyFailure) -> Test.TestTree applyFailureTest (ver, ver', expected) =- testCase (showVersion ver ++ " -> " ++ showVersion ver') $+ HUnit.testCase (showVersion ver ++ " -> " ++ showVersion ver') $ case migrateDataDump (startSchema, ver) (endSchema, Release ver') badChangelog testMigration root_ CheckAll startData of- Right _ -> assertFailure $ "Successful migration!"+ Right _ -> HUnit.assertFailure $ "Successful migration!" Left (ValidateFailure (ChangelogEntryInvalid _ _ err)) | err == expected -> return ()- Left err -> assertFailure $ unlines $ ["Unexpected failure:"]+ Left err -> HUnit.assertFailure $ unlines $ ["Unexpected failure:"] ++ indent (ppLines err) ++ ["Expecting:"] ++ indent (ppLines expected) migrateFailureTest :: MigrateFailureTest -> Test.TestTree migrateFailureTest (s, start, end, clog, db, expected) =- testCase s $ case migrateDataDump start end clog testMigration root_ CheckAll db of- Right _ -> assertFailure $ "Successful migration!"+ HUnit.testCase s $ case migrateDataDump start end clog testMigration root_ CheckAll db of+ Right _ -> HUnit.assertFailure $ "Successful migration!" Left err | expected err -> return ()- | otherwise -> assertFailure $ unlines $ ["Unexpected failure:"]+ | otherwise -> HUnit.assertFailure $ unlines $ ["Unexpected failure:"] ++ indent (ppLines err) @@ -212,9 +212,9 @@ migrationTests :: TestTree migrationTests = testGroup "Migration"- [ testCase "Basic migration using sample changelog" basicMigrationTest- , testGroup "Invalid changes" $ map applyFailureTest expectedApplyFailures- , testGroup "Invalid migrations" $ map migrateFailureTest expectedMigrateFailures+ [ HUnit.testCase "Basic migration using sample changelog" basicMigrationTest+ , testGroup "Invalid changes" $ map applyFailureTest expectedApplyFailures+ , testGroup "Invalid migrations" $ map migrateFailureTest expectedMigrateFailures , QC.testProperty "Valid migrations (JSON)" validMigrationProperty , QC.testProperty "Valid migrations (generic)" validMigrationProperty' ]