From 08973f15baeae72971fb8b3c912cbd2e0b041419 Mon Sep 17 00:00:00 2001 From: philopon Date: Tue, 26 Aug 2014 21:07:57 +0900 Subject: [PATCH] update travis. --- .travis-script.sh | 7 +++++++ .travis.yml | 1 + memcached-binary.cabal | 13 +++++++++++++ test/test.hs | 24 ++++++++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 .travis-script.sh create mode 100644 test/test.hs diff --git a/.travis-script.sh b/.travis-script.sh new file mode 100644 index 0000000..9c9f932 --- /dev/null +++ b/.travis-script.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +memcached & + +cabal configure --enable-tests +cabal build +cabal test diff --git a/.travis.yml b/.travis.yml index 5c7e760..9156e80 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,3 +2,4 @@ language: haskell ghc: - 7.8 - 7.6 +script: bash -eu .travis-script.sh diff --git a/memcached-binary.cabal b/memcached-binary.cabal index e2758a5..9b825a7 100644 --- a/memcached-binary.cabal +++ b/memcached-binary.cabal @@ -28,3 +28,16 @@ library ghc-options: -Wall -O2 hs-source-dirs: src default-language: Haskell2010 + +test-suite test + type: exitcode-stdio-1.0 + hs-source-dirs: test + main-is: test.hs + ghc-options: -Wall -O2 + build-depends: base >=4.6 && <4.8 + , memcached-binary + , test-framework >=0.8 && <0.9 + , test-framework-hunit >=0.3 && <0.4 + , process >=1.2 && <1.3 + , network >=2.6 && <2.7 + default-language: Haskell2010 diff --git a/test/test.hs b/test/test.hs new file mode 100644 index 0000000..43b2250 --- /dev/null +++ b/test/test.hs @@ -0,0 +1,24 @@ +{-# LANGUAGE ScopedTypeVariables #-} +import Control.Exception +import Control.Concurrent +import Control.Monad +import Network +import System.Process +import Database.Memcached.Binary +import Test.Framework +import Test.Framework.Providers.HUnit + +startMemcached :: IO ProcessHandle +startMemcached = do + h <- spawnProcess "memcached" [] + wait (100 :: Int) + return h + where + wait 0 = fail "cannot start server" + wait i = handle (\(_ ::SomeException) -> threadDelay 100000 >> wait (i-1)) $ + void $ connectTo "localhost" $ PortNumber 11211 + +main :: IO () +main = bracket startMemcached terminateProcess $ \_ -> defaultMain + [ testCase "version" . void $ withConnection def version + ]