Skip to content

Commit

Permalink
add test for non-vanilla profiling and dynamic builds with Template H…
Browse files Browse the repository at this point in the history
…askell
  • Loading branch information
int-e committed Aug 23, 2012
1 parent 6ed73cd commit 96c3f33
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cabal/Cabal.cabal
Expand Up @@ -150,6 +150,7 @@ test-suite unit-tests
PackageTests.TestStanza.Check, PackageTests.TestStanza.Check,
PackageTests.TestSuiteExeV10.Check, PackageTests.TestSuiteExeV10.Check,
PackageTests.BenchmarkStanza.Check, PackageTests.BenchmarkStanza.Check,
PackageTests.TemplateHaskell.Check,
PackageTests.PackageTester PackageTests.PackageTester
hs-source-dirs: tests hs-source-dirs: tests
build-depends: build-depends:
Expand Down
44 changes: 44 additions & 0 deletions Cabal/tests/PackageTests/TemplateHaskell/Check.hs
@@ -0,0 +1,44 @@
module PackageTests.TemplateHaskell.Check where

import Test.HUnit
import System.FilePath
import PackageTests.PackageTester
import Data.List (isInfixOf, intercalate)
import Distribution.Version
import Distribution.PackageDescription.Parse
( readPackageDescription )
import Distribution.PackageDescription.Configuration
( finalizePackageDescription )
import Distribution.Package
( PackageIdentifier(..), PackageName(..), Dependency(..) )
import Distribution.PackageDescription
( PackageDescription(..), BuildInfo(..), TestSuite(..), Library(..)
, TestSuiteInterface(..)
, TestType(..), emptyPackageDescription, emptyBuildInfo, emptyLibrary
, emptyTestSuite, BuildType(..) )
import Distribution.Verbosity (silent)
import Distribution.License (License(..))
import Distribution.ModuleName (fromString)
import Distribution.System (buildPlatform)
import Distribution.Compiler
( CompilerId(..), CompilerFlavor(..) )
import Distribution.Text

profiling :: Test
profiling = TestCase $ do
let flags = ["--disable-library-vanilla"
,"--enable-library-profiling"
,"--enable-executable-profiling"]
spec = PackageSpec ("PackageTests" </> "TemplateHaskell" </> "profiling") flags
result <- cabal_build spec
assertEqual "cabal build should succeed - see test-log.txt" True (successful result)

dynamic :: Test
dynamic = TestCase $ do
let flags = ["--disable-library-vanilla"
,"--enable-shared"
,"--enable-executable-dynamic"]
spec = PackageSpec ("PackageTests" </> "TemplateHaskell" </> "dynamic") flags
result <- cabal_build spec
assertEqual "cabal build should succeed - see test-log.txt" True (successful result)

6 changes: 6 additions & 0 deletions Cabal/tests/PackageTests/TemplateHaskell/dynamic/Exe.hs
@@ -0,0 +1,6 @@
{-# LANGUAGE TemplateHaskell #-}
module Main where

import TH

main = print $(splice)
6 changes: 6 additions & 0 deletions Cabal/tests/PackageTests/TemplateHaskell/dynamic/Lib.hs
@@ -0,0 +1,6 @@
{-# LANGUAGE TemplateHaskell #-}
module Lib where

import TH

val = $(splice)
3 changes: 3 additions & 0 deletions Cabal/tests/PackageTests/TemplateHaskell/dynamic/Setup.hs
@@ -0,0 +1,3 @@
import Distribution.Simple
main = defaultMain

4 changes: 4 additions & 0 deletions Cabal/tests/PackageTests/TemplateHaskell/dynamic/TH.hs
@@ -0,0 +1,4 @@
{-# LANGUAGE TemplateHaskell #-}
module TH where

splice = [| () |]
15 changes: 15 additions & 0 deletions Cabal/tests/PackageTests/TemplateHaskell/dynamic/my.cabal
@@ -0,0 +1,15 @@
Name: templateHaskell
Version: 0.1
Build-Type: Simple
Cabal-Version: >= 1.2

Library
Exposed-Modules: Lib
Other-Modules: TH
Build-Depends: base, template-haskell
Extensions: TemplateHaskell

Executable main
Main-is: Exe.hs
Build-Depends: base, template-haskell
Extensions: TemplateHaskell
6 changes: 6 additions & 0 deletions Cabal/tests/PackageTests/TemplateHaskell/profiling/Exe.hs
@@ -0,0 +1,6 @@
{-# LANGUAGE TemplateHaskell #-}
module Main where

import TH

main = print $(splice)
6 changes: 6 additions & 0 deletions Cabal/tests/PackageTests/TemplateHaskell/profiling/Lib.hs
@@ -0,0 +1,6 @@
{-# LANGUAGE TemplateHaskell #-}
module Lib where

import TH

val = $(splice)
3 changes: 3 additions & 0 deletions Cabal/tests/PackageTests/TemplateHaskell/profiling/Setup.hs
@@ -0,0 +1,3 @@
import Distribution.Simple
main = defaultMain

4 changes: 4 additions & 0 deletions Cabal/tests/PackageTests/TemplateHaskell/profiling/TH.hs
@@ -0,0 +1,4 @@
{-# LANGUAGE TemplateHaskell #-}
module TH where

splice = [| () |]
15 changes: 15 additions & 0 deletions Cabal/tests/PackageTests/TemplateHaskell/profiling/my.cabal
@@ -0,0 +1,15 @@
Name: templateHaskell
Version: 0.1
Build-Type: Simple
Cabal-Version: >= 1.2

Library
Exposed-Modules: Lib
Other-Modules: TH
Build-Depends: base, template-haskell
Extensions: TemplateHaskell

Executable main
Main-is: Exe.hs
Build-Depends: base, template-haskell
Extensions: TemplateHaskell
5 changes: 4 additions & 1 deletion Cabal/tests/suite.hs
Expand Up @@ -28,6 +28,7 @@ import PackageTests.BuildDeps.InternalLibrary4.Check
import PackageTests.TestOptions.Check import PackageTests.TestOptions.Check
import PackageTests.TestStanza.Check import PackageTests.TestStanza.Check
import PackageTests.TestSuiteExeV10.Check import PackageTests.TestSuiteExeV10.Check
import PackageTests.TemplateHaskell.Check
import Distribution.Text (display) import Distribution.Text (display)
import Distribution.Simple.Utils (cabalVersion) import Distribution.Simple.Utils (cabalVersion)
import Data.Version import Data.Version
Expand Down Expand Up @@ -55,7 +56,9 @@ tests cabalVersion = [
-- only for higher versions. -- only for higher versions.
hunit "PackageTests/BenchmarkExeV10/Test" hunit "PackageTests/BenchmarkExeV10/Test"
(PackageTests.BenchmarkExeV10.Check.checkBenchmark cabalVersion), (PackageTests.BenchmarkExeV10.Check.checkBenchmark cabalVersion),
hunit "PackageTests/BenchmarkOptions" PackageTests.BenchmarkOptions.Check.suite hunit "PackageTests/BenchmarkOptions" PackageTests.BenchmarkOptions.Check.suite,
hunit "PackageTests/TemplateHaskell/profiling" PackageTests.TemplateHaskell.Check.profiling,
hunit "PackageTests/TemplateHaskell/dynamic" PackageTests.TemplateHaskell.Check.dynamic
] ++ ] ++
-- These tests are only required to pass on cabal version >= 1.7 -- These tests are only required to pass on cabal version >= 1.7
(if cabalVersion >= Version [1, 7] [] (if cabalVersion >= Version [1, 7] []
Expand Down

0 comments on commit 96c3f33

Please sign in to comment.