Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #13 from basvandijk/cabal-test-suite

Add a Cabal test-suite section
  • Loading branch information...
commit 18cf331e1ee07781a1261ff933391d93cf519dd3 2 parents f8b1c59 + e9dc9dc
@bos authored
View
21 configurator.cabal
@@ -38,7 +38,8 @@ description:
extra-source-files:
README.markdown
- tests/*.hs
+
+data-files: tests/resources/*.cfg
flag developer
description: operate in developer mode
@@ -63,7 +64,7 @@ library
hashable,
text >= 0.11.1.0,
unix-compat,
- unordered-containers
+ unordered-containers
if flag(developer)
ghc-options: -Werror
@@ -78,3 +79,19 @@ source-repository head
source-repository head
type: mercurial
location: http://bitbucket.org/bos/configurator
+
+test-suite test-case-insensitive
+ type: exitcode-stdio-1.0
+ main-is: Test.hs
+ hs-source-dirs: tests
+ Build-depends: configurator,
+ base,
+ directory,
+ HUnit,
+ text,
+ attoparsec,
+ unordered-containers,
+ unix-compat,
+ hashable,
+ bytestring
+ Ghc-options: -Wall -fno-warn-unused-do-bind
View
2  tests/Setup.hs
@@ -1,2 +0,0 @@
-import Distribution.Simple
-main = defaultMain
View
21 tests/Test.hs
@@ -20,6 +20,7 @@ import System.Directory
import System.Environment
import System.IO
import Test.HUnit
+import Paths_configurator
main :: IO ()
main = runTestTT tests >> return ()
@@ -72,7 +73,9 @@ takeMVarTimeout millis v = do
takeMVar w
loadTest :: Assertion
-loadTest = withLoad [Required "resources/pathological.cfg"] $ \cfg -> do
+loadTest = do
+ fp <- getDataFileName "tests/resources/pathological.cfg"
+ withLoad [Required fp] $ \cfg -> do
aa <- lookup cfg "aa"
assertEqual "int property" aa $ (Just 1 :: Maybe Int)
@@ -98,7 +101,9 @@ loadTest = withLoad [Required "resources/pathological.cfg"] $ \cfg -> do
assertEqual "deep bool" deep (Just False :: Maybe Bool)
typesTest :: Assertion
-typesTest = withLoad [Required "resources/pathological.cfg"] $ \ cfg -> do
+typesTest = do
+ fp <- getDataFileName "tests/resources/pathological.cfg"
+ withLoad [Required fp] $ \ cfg -> do
asInt <- lookup cfg "aa" :: IO (Maybe Int)
assertEqual "int" asInt (Just 1)
@@ -148,20 +153,26 @@ typesTest = withLoad [Required "resources/pathological.cfg"] $ \ cfg -> do
assertEqual "char" asChar (Just 'x')
interpTest :: Assertion
-interpTest = withLoad [Required "resources/pathological.cfg"] $ \ cfg -> do
+interpTest = do
+ fp <- getDataFileName "tests/resources/pathological.cfg"
+ withLoad [Required fp] $ \ cfg -> do
home <- getEnv "HOME"
cfgHome <- lookup cfg "ba"
assertEqual "home interp" (Just home) cfgHome
importTest :: Assertion
-importTest = withLoad [Required "resources/import.cfg"] $ \ cfg -> do
+importTest = do
+ fp <- getDataFileName "tests/resources/import.cfg"
+ withLoad [Required fp] $ \ cfg -> do
aa <- lookup cfg "x.aa" :: IO (Maybe Int)
assertEqual "simple" aa (Just 1)
acx <- lookup cfg "x.ac.x" :: IO (Maybe Int)
assertEqual "nested" acx (Just 1)
reloadTest :: Assertion
-reloadTest = withReload [Required "resources/pathological.cfg"] $ \[Just f] cfg -> do
+reloadTest = do
+ fp <- getDataFileName "tests/resources/pathological.cfg"
+ withReload [Required fp] $ \[Just f] cfg -> do
aa <- lookup cfg "aa"
assertEqual "simple property 1" aa $ Just (1 :: Int)
View
18 tests/configurator-tests.cabal
@@ -1,18 +0,0 @@
-Name: configurator-tests
-Version: 0.1
-Build-type: Simple
-Cabal-version: >=1.2
-
-Executable configurator-test
- Main-is: Test.hs
- Hs-source-dirs: ., ..
- Build-depends: base,
- directory,
- HUnit,
- text,
- attoparsec-text,
- unordered-containers,
- unix-compat,
- hashable,
- bytestring
- Ghc-options: -Wall -fhpc -fno-warn-unused-do-bind
View
17 tests/runTests.sh
@@ -1,17 +0,0 @@
-#!/bin/sh
-cabal configure
-cabal build
-
-rm -f configurator-test.tix
-./dist/build/configurator-test/configurator-test
-
-HPCDIR=dist/hpc
-
-rm -rf $HPCDIR
-mkdir -p $HPCDIR
-
-EXCLUDES='--exclude=Main
- --exclude=Data.Configurator.Types'
-hpc markup $EXCLUDES --destdir=$HPCDIR configurator-test
-
-rm -f configurator-test.tix
Please sign in to comment.
Something went wrong with that request. Please try again.