From 205ed82460c2b8c3f94cc30a338f315baa315dbf Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 19 Aug 2012 14:01:00 -0400 Subject: [PATCH] Remove the test-framework-doctest dependency. Split the doctests out into a new file, Doctests.hs. Integrate all tests with cabal. --- makefile | 18 ++++++++-- spline3.cabal | 85 +++++++++++++++++++++++++++++++++++++++++++---- test/Doctests.hs | 7 ++++ test/TestSuite.hs | 7 ++-- 4 files changed, 103 insertions(+), 14 deletions(-) create mode 100644 test/Doctests.hs diff --git a/makefile b/makefile index 236c495..78bf454 100644 --- a/makefile +++ b/makefile @@ -1,10 +1,22 @@ +BIN = dist/build/spline3/spline3 +DOCTESTS_BIN = dist/build/doctests/doctests +TESTSUITE_BIN = dist/build/testsuite/testsuite + .PHONY : test publish_doc doc src_html hlint -spline3: src/*.hs +$(BIN): src/*.hs runghc Setup.hs clean runghc Setup.hs configure --user --flags=${FLAGS} runghc Setup.hs build +$(DOCTESTS_BIN): src/*.hs test/Doctests.hs + runghc Setup.hs configure --user --flags=${FLAGS} --enable-tests + runghc Setup.hs build + +$(TESTSUITE_BIN): src/*.hs test/TestSuite.hs + runghc Setup.hs configure --user --flags=${FLAGS} --enable-tests + runghc Setup.hs build + llvm: src/*.hs FLAGS="llvm" make @@ -21,8 +33,8 @@ clean: rm -f *.prof rm -rf .hpc -test: - runghc -i"src" test/TestSuite.hs +test: $(BIN) $(DOCTESTS_BIN) $(TESTSUITE_BIN) + runghc Setup.hs test src_html: util/hscolour_srcs diff --git a/spline3.cabal b/spline3.cabal index e65f0cc..a1be0aa 100644 --- a/spline3.cabal +++ b/spline3.cabal @@ -16,21 +16,21 @@ flag LLVM description: Build with LLVM default: False + executable spline3 build-depends: base == 4.5.*, - doctest == 0.7.*, filepath == 1.*, - HUnit == 1.2.*, - QuickCheck == 2.*, repa == 3.2.*, repa-algorithms == 3.2.*, repa-io == 3.2.*, + vector == 0.9.*, + -- Additional test dependencies. + HUnit == 1.2.*, + QuickCheck == 2.*, test-framework == 0.6.*, - test-framework-doctest == 0.2.*, test-framework-hunit == 0.2.*, - test-framework-quickcheck2 == 0.2.*, - vector == 0.9.* + test-framework-quickcheck2 == 0.2.* main-is: Main.hs @@ -74,3 +74,76 @@ executable spline3 -prof -auto-all -caf-all + + +test-suite doctests + type: exitcode-stdio-1.0 + hs-source-dirs: test + main-is: Doctests.hs + build-depends: + base == 4.5.*, + -- Additional test dependencies. + doctest == 0.7.* + + -- It's not entirely clear to me why I have to reproduce all of this. + ghc-options: + -rtsopts + -threaded + -funbox-strict-fields + -fexcess-precision + -fno-spec-constr-count + + if flag(llvm) + ghc-options: + -fllvm + -optlo-O3 + -optlc-O3 + else + ghc-options: + -O2 + -optc-O3 + -optc-march=native + + +test-suite testsuite + type: exitcode-stdio-1.0 + hs-source-dirs: src test + main-is: TestSuite.hs + build-depends: + base == 4.5.*, + filepath == 1.*, + repa == 3.2.*, + repa-algorithms == 3.2.*, + repa-io == 3.2.*, + vector == 0.9.*, + -- Additional test dependencies. + HUnit == 1.2.*, + QuickCheck == 2.*, + test-framework == 0.6.*, + test-framework-hunit == 0.2.*, + test-framework-quickcheck2 == 0.2.* + + -- It's not entirely clear to me why I have to reproduce all of this. + ghc-options: + -rtsopts + -threaded + -funbox-strict-fields + -fexcess-precision + -fno-spec-constr-count + + if flag(llvm) + ghc-options: + -fllvm + -optlo-O3 + -optlc-O3 + else + ghc-options: + -O2 + -optc-O3 + -optc-march=native + + +source-repository head + type: git + location: http://michael.orlitzky.com/git/spline3.git + branch: master diff --git a/test/Doctests.hs b/test/Doctests.hs new file mode 100644 index 0000000..34b7b0c --- /dev/null +++ b/test/Doctests.hs @@ -0,0 +1,7 @@ +module Main +where + +import Test.DocTest + +main :: IO () +main = doctest ["--optghc=-isrc", "src/Everything.hs"] diff --git a/test/TestSuite.hs b/test/TestSuite.hs index 0491f56..4a0b405 100644 --- a/test/TestSuite.hs +++ b/test/TestSuite.hs @@ -1,4 +1,4 @@ -module TestSuite +module Main where import Data.Monoid (mempty) @@ -13,7 +13,6 @@ import Test.Framework ( import Test.Framework.Options import Test.Framework.Runners.Options import Test.Framework.Providers.API (TestName) -import Test.Framework.Providers.DocTest import Test.Framework.Providers.HUnit (testCase) import Test.Framework.Providers.QuickCheck2 (testProperty) import Test.HUnit @@ -28,8 +27,6 @@ import Tetrahedron (tetrahedron_tests, tetrahedron_properties) main :: IO () main = do - dt <- docTest ["src/Everything.hs"] ["-isrc"] - let empty_test_opts = mempty :: TestOptions let my_test_opts = empty_test_opts { topt_maximum_generated_tests = Just 500 @@ -40,7 +37,7 @@ main = do ropt_test_options = Just my_test_opts } - defaultMainWithOpts ([dt] ++ tests) my_runner_opts + defaultMainWithOpts tests my_runner_opts -- | Defined so that my test names fit on one line. -- 2.43.2