Skip to content
Browse files

Enabled "cabal test" support and other Cabal fixes.

Running "cabal check" no longer complains of anything. Running "cabal
haddock" reports 100% coverage.
  • Loading branch information...
1 parent 6508e0a commit e91c05eb73fea65b2f61755499d31f9a42f5b28a @malcolmt committed
View
3 .gitignore
@@ -4,5 +4,6 @@ html/
*.hi
*.o
*.tix
-Suite
+CabalTest
+ConsoleTest
View
30 chess-tools.cabal
@@ -30,8 +30,12 @@ Build-type: Simple
Homepage: https://github.com/malcolmt/chess-tools/
Bug-reports: https://github.com/malcolmt/chess-tools/issues
+-- Need to list test source files in extra-source-files until a version of
+-- Cabal fixing http://hackage.haskell.org/trac/hackage/ticket/792 is in
+-- general use.
Extra-source-files: README.md
TODO.otl
+ src/ChessTools/Test/*.hs
Cabal-version: >= 1.10
@@ -43,19 +47,27 @@ Source-repository head
Library
Exposed-modules: ChessTools.Board
ChessTools.Board.Internal
+ ChessTools.Board.Western
Default-language: Haskell2010
Hs-Source-Dirs: src
- GHC-Options: -Wall -Werror -O
- Build-depends: haskell2010
+ GHC-Options: -Wall
+ Build-depends: base < 5.0,
+ array >= 0.3 && < 1.0
--- TODO: Wrestle this to the ground. Still a little problematic.
+Test-Suite test-chess-tools
+ Type: exitcode-stdio-1.0
+ Main-is: ChessTools/Test/CabalTest.hs
+ Hs-source-dirs: src
+ Default-language: Haskell2010
+
+ Build-depends: base < 5.0,
+ array >= 0.3 && < 1.0,
+ Cabal >= 1.10,
+ test-framework >= 0.4.1 && < 1.0,
+ test-framework-quickcheck2 >= 0.2.10 && < 1.0,
+ QuickCheck >= 2.4.0.1 && < 3.0
--- Test-Suite test-chess-tools
--- Type: detailed-1.0
--- Test-module: Tests
--- Hs-source-dirs: test
--- Build-depends: haskell2010
--- Cabal >= 1.10
+ GHC-Options: -Wall
View
4 src/ChessTools/Board/Western.hs
@@ -13,10 +13,12 @@ import Data.Char (ord, chr)
import ChessTools.Board
+-- | The 'BoardSize' for a western-style chessboard.
westernBoardSize :: BoardSize
westernBoardSize = BoardSize 8 8 2
-- XXX: Not yet used; commented out to maintain warning-free build.
+-- | A 'CoveringIndexList' appropriate for a western-style chessboard size.
-- coveringIndices :: CoveringIndexList
-- coveringIndices = repIndexList westernBoardSize
@@ -32,7 +34,7 @@ algebraicToIndex _ = Nothing
-- | Converts an index into a board array back into an algebraic notation
--- square designation, such as "/e5/".
+-- square designation, such as /"e5"/.
indexToAlgebraic :: BIndex -> Maybe String
indexToAlgebraic x = case sq of
Just (Square (f, r)) -> Just $ chr (f + ord 'a') : [chr (r + ord '1')]
View
19 src/ChessTools/Test/CabalTest.hs
@@ -0,0 +1,19 @@
+{-
+ - The driver file for running the tests via "cabal test". This is slightly
+ - different to how we might run them from the command line, since suppressing
+ - ANSI output is forced in this case (otherwise the log file is completely
+ - messed up).
+ -}
+
+module Main (main) where
+
+import Data.Monoid (mempty)
+import Test.Framework
+
+import ChessTools.Test.Suite (tests)
+
+
+main :: IO ()
+main = defaultMainWithOpts tests options
+ where options = (mempty :: RunnerOptions) {ropt_plain_output = Just True}
+
View
15 src/ChessTools/Test/ConsoleTest.hs
@@ -0,0 +1,15 @@
+{-
+ - Driver file for running tests at a command line prompt. This is the standard
+ - pass-through to the test-framework package.
+ -
+ - Refer to CabalTest.hs for the setup used when running "cabal test".
+ -}
+
+module Main (main) where
+
+import Test.Framework (defaultMain)
+import ChessTools.Test.Suite (tests)
+
+main :: IO ()
+main = defaultMain tests
+
View
15 src/ChessTools/Test/Suite.hs
@@ -1,21 +1,20 @@
{-
- - Runs all the tests and provides a nice summary output, using the
- - test-framework library.
+ - Grouping of tests into groups and giving them readable names.
-
- - Useful during development. During deployment situations, "cabal test" is
- - going to be more appropriate.
+ - Runner files for these tests are in ConsoleTest.hs and CabalTest.hs.
-}
-import Test.Framework (defaultMain, testGroup, Test)
+module ChessTools.Test.Suite (
+ tests
+) where
+
+import Test.Framework (testGroup, Test)
import Test.Framework.Providers.QuickCheck2 (testProperty)
import ChessTools.Test.Board
import ChessTools.Test.WesternBoard
-main :: IO ()
-main = defaultMain tests
-
tests :: [Test]
tests = [
testGroup "Board arrays" [

0 comments on commit e91c05e

Please sign in to comment.
Something went wrong with that request. Please try again.