Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add test for non-vanilla profiling and dynamic builds with Template H…

…askell
  • Loading branch information...
commit 96c3f33f1213fdff8d175a7db053f2066f5b3eea 1 parent 6ed73cd
@int-e int-e authored
View
1  Cabal/Cabal.cabal
@@ -150,6 +150,7 @@ test-suite unit-tests
PackageTests.TestStanza.Check,
PackageTests.TestSuiteExeV10.Check,
PackageTests.BenchmarkStanza.Check,
+ PackageTests.TemplateHaskell.Check,
PackageTests.PackageTester
hs-source-dirs: tests
build-depends:
View
44 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)
+
View
6 Cabal/tests/PackageTests/TemplateHaskell/dynamic/Exe.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE TemplateHaskell #-}
+module Main where
+
+import TH
+
+main = print $(splice)
View
6 Cabal/tests/PackageTests/TemplateHaskell/dynamic/Lib.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE TemplateHaskell #-}
+module Lib where
+
+import TH
+
+val = $(splice)
View
3  Cabal/tests/PackageTests/TemplateHaskell/dynamic/Setup.hs
@@ -0,0 +1,3 @@
+import Distribution.Simple
+main = defaultMain
+
View
4 Cabal/tests/PackageTests/TemplateHaskell/dynamic/TH.hs
@@ -0,0 +1,4 @@
+{-# LANGUAGE TemplateHaskell #-}
+module TH where
+
+splice = [| () |]
View
15 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
View
6 Cabal/tests/PackageTests/TemplateHaskell/profiling/Exe.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE TemplateHaskell #-}
+module Main where
+
+import TH
+
+main = print $(splice)
View
6 Cabal/tests/PackageTests/TemplateHaskell/profiling/Lib.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE TemplateHaskell #-}
+module Lib where
+
+import TH
+
+val = $(splice)
View
3  Cabal/tests/PackageTests/TemplateHaskell/profiling/Setup.hs
@@ -0,0 +1,3 @@
+import Distribution.Simple
+main = defaultMain
+
View
4 Cabal/tests/PackageTests/TemplateHaskell/profiling/TH.hs
@@ -0,0 +1,4 @@
+{-# LANGUAGE TemplateHaskell #-}
+module TH where
+
+splice = [| () |]
View
15 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
View
5 Cabal/tests/suite.hs
@@ -28,6 +28,7 @@ import PackageTests.BuildDeps.InternalLibrary4.Check
import PackageTests.TestOptions.Check
import PackageTests.TestStanza.Check
import PackageTests.TestSuiteExeV10.Check
+import PackageTests.TemplateHaskell.Check
import Distribution.Text (display)
import Distribution.Simple.Utils (cabalVersion)
import Data.Version
@@ -55,7 +56,9 @@ tests cabalVersion = [
-- only for higher versions.
hunit "PackageTests/BenchmarkExeV10/Test"
(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
(if cabalVersion >= Version [1, 7] []
Please sign in to comment.
Something went wrong with that request. Please try again.