Commit 751e3449 authored by tibbe's avatar tibbe
Browse files

Add unit test for building benchmarks

parent e702bfd2
module PackageTests.BenchmarkExeV10.Check
( checkBenchmark
) where
import Distribution.PackageDescription ( Benchmark(..), emptyBenchmark )
import Distribution.Simple.Hpc
import Distribution.Version
import Test.HUnit
import System.Directory
import System.FilePath
import PackageTests.PackageTester
dir :: FilePath
dir = "PackageTests" </> "BenchmarkExeV10"
checkBenchmark :: Version -> Test
checkBenchmark cabalVersion = TestCase $ do
let spec = PackageSpec dir ["--enable-benchmarks"]
buildResult <- cabal_build spec
let buildMessage = "\'setup build\' should succeed"
assertEqual buildMessage True $ successful buildResult
module Foo where
fooTest :: [String] -> Bool
fooTest _ = True
import Distribution.Simple
main = defaultMain
module Main where
import Foo
import System.Exit
main :: IO ()
main | fooTest [] = exitSuccess
| otherwise = exitFailure
name: my
version: 0.1
license: BSD3
cabal-version: >= 1.9.2
build-type: Simple
exposed-modules: Foo
build-depends: base
benchmark bench-Foo
type: exitcode-stdio-1.0
hs-source-dirs: benchmarks
main-is: bench-Foo.hs
build-depends: base, my
......@@ -10,6 +10,7 @@ import Test.Framework
import Test.Framework.Providers.HUnit
import Test.Framework.Providers.QuickCheck2
import qualified Test.HUnit as HUnit
import PackageTests.BenchmarkExeV10.Check
import PackageTests.BenchmarkStanza.Check
import PackageTests.BuildDeps.SameDepsAllRound.Check
import PackageTests.BuildDeps.TargetSpecificDeps1.Check
......@@ -48,7 +49,9 @@ tests cabalVersion = [
hunit "PackageTests/TestSuiteExeV10/TestWithHpc"
(PackageTests.TestSuiteExeV10.Check.checkTestWithHpc cabalVersion),
hunit "PackageTests/TestOptions" PackageTests.TestOptions.Check.suite,
hunit "PackageTests/BenchmarkStanza/" (PackageTests.BenchmarkStanza.Check.suite cabalVersion)
hunit "PackageTests/BenchmarkStanza/" (PackageTests.BenchmarkStanza.Check.suite cabalVersion),
hunit "PackageTests/BenchmarkExeV10/Test"
(PackageTests.BenchmarkExeV10.Check.checkBenchmark cabalVersion)
-- ^ The benchmark stanza test will eventually be required
-- only for higher versions.
] ++
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment