git.iko.soy/typeable/hjsonschema
on master help sign in
Merge pull request #13 from mdorman/auto-testing

Automate testing with Travis This required forking off a static server in our "remote" tests, setting up the Travis config, and while I was at it, I relaxed the lower bounds on base and aeson so they'll build with ghc 7.6.

commit321ec3ed2d56136dd4995d30c986a07cb02a3321 authorMichael Alan Dorman <mdorman@jaunder.io> dateThu 30 Apr 2015, 17:53 (11 years ago) parent7ba0a27395a65f
4 files changed+41−16
.travis.yml+24 README.md−8 hjsonschema.cabal+6−2 tests/Remote.hs+11−6
.travis.ymlnew file+24
@@ -0,0 +1,24 @@
1+language: haskell
2+
3+ghc:
4+ - 7.6
5+ - 7.8
6+
7+before_install:
8+ - cabal install alex happy
9+
10+script:
11+ - cabal configure --enable-tests
12+ - cabal test
13+ - cabal check
14+ - cabal sdist
15+
16+ # check that the generated source-distribution can be built & installed
17+ - export SRC_TGZ=$(cabal info . | awk '{print $2 ".tar.gz";exit}') ;
18+ cd dist/;
19+ if [ -f "$SRC_TGZ" ]; then
20+ cabal install "$SRC_TGZ";
21+ else
22+ echo "expected '$SRC_TGZ' not found";
23+ exit 1;
24+ fi
README.md−8
@@ -48,14 +48,6 @@ fromList ["Val error against uniqueItems True for: Array (fromList [String \"foo
4848
4949 git submodule update --init
5050
51−# Prepare Tests
52−
53−+ `cd JSON-Schema-Test-Suite/remotes`
54−
55−+ `hserv --port=1234` / `python -m SimpleHTTPServer 1234`
56−
57−Note that the `remote` test suite requires an internet connection.
58−
5951# Notes
6052
6153+ This uses the [regexpr](https://hackage.haskell.org/package/regexpr-0.5.4) regular expression library for the "pattern" validator. I have no idea if this is compatible with the ECMA 262 regex dialect, which the [spec](http://json-schema.org/latest/json-schema-validation.html#anchor33) requires.
hjsonschema.cabal+6−2
@@ -1,6 +1,7 @@
11name: hjsonschema
22version: 0.5.3.1
33synopsis: JSON Schema Draft 4 library
4+description: Check your Aeson structures against json-schema descriptions
45homepage: https://github.com/seagreen/hjsonschema
56license: MIT
67license-file: MIT-LICENSE.txt
@@ -26,8 +27,8 @@ library
2627 default-extensions: OverloadedStrings
2728 other-extensions: TemplateHaskell
2829 ghc-options: -Wall
29− build-depends: aeson >= 0.8 && < 0.9
30− , base >= 4.7 && < 4.9
30+ build-depends: aeson >= 0.7 && < 0.9
31+ , base >= 4.6 && < 4.9
3132 , bytestring >= 0.10 && < 0.11
3233 , file-embed >= 0.0.8 && < 0.0.9
3334 , hashable >= 1.2 && < 1.3
@@ -70,6 +71,7 @@ test-suite remote
7071 default-extensions: OverloadedStrings
7172 other-extensions: TemplateHaskell
7273 build-depends: aeson
74+ , async
7375 , base
7476 , bytestring
7577 , hjsonschema
@@ -81,6 +83,8 @@ test-suite remote
8183 , HUnit >= 1.2 && < 1.3
8284 , test-framework >= 0.8 && < 0.9
8385 , test-framework-hunit >= 0.3 && < 0.4
86+ , wai-app-static
87+ , warp
8488
8589source-repository head
8690 type: git
tests/Remote.hs+11−6
@@ -1,17 +1,22 @@
11module Main where
22
33import Control.Applicative
4−import Data.List (isSuffixOf)
4+import Control.Concurrent.Async (withAsync)
5+import Data.List (isSuffixOf)
56import Lib
6−import System.Directory (getDirectoryContents)
7+import Network.Wai.Application.Static (defaultFileServerSettings,
8+ staticApp)
9+import Network.Wai.Handler.Warp (run)
10+import System.Directory (getDirectoryContents)
711import Test.Framework
812
913main :: IO ()
10−main = do
11− filenames <- filter (not . isLocal) . filter (".json" `isSuffixOf`)
14+main =
15+ withAsync (run 1234 $ staticApp $ defaultFileServerSettings "JSON-Schema-Test-Suite/remotes") $ \_ -> do
16+ filenames <- filter (not . isLocal) . filter (".json" `isSuffixOf`)
1217 <$> getDirectoryContents dir
13− ts <- readSchemaTests dir filenames
14− defaultMain (toTest <$> ts)
18+ ts <- readSchemaTests dir filenames
19+ defaultMain (toTest <$> ts)
1520
1621 where
1722 dir :: String