PackageTests.hs 5.41 KB
Newer Older
1
2
3
4
5
6
7
8
-- The intention is that this will be the new unit test framework.
-- Please add any working tests here.  This file should do nothing
-- but import tests from other modules.
--
-- Stephen Blackheath, 2009

module Main where

9
import Data.Version (Version(Version))
tibbe's avatar
tibbe committed
10
11
import Distribution.Simple.Utils (cabalVersion)
import Distribution.Text (display)
12
13
import System.Directory (getCurrentDirectory, setCurrentDirectory)
import System.FilePath ((</>))
14
15
import Test.Framework (Test, TestName, defaultMain, testGroup)
import Test.Framework.Providers.HUnit (hUnitTestToTests)
16
import qualified Test.HUnit as HUnit
tibbe's avatar
tibbe committed
17

tibbe's avatar
tibbe committed
18
import PackageTests.BenchmarkExeV10.Check
19
import PackageTests.BenchmarkOptions.Check
tibbe's avatar
tibbe committed
20
import PackageTests.BenchmarkStanza.Check
tibbe's avatar
tibbe committed
21
22
-- import PackageTests.BuildDeps.GlobalBuildDepsNotAdditive1.Check
-- import PackageTests.BuildDeps.GlobalBuildDepsNotAdditive2.Check
23
import PackageTests.BuildDeps.InternalLibrary0.Check
24
25
26
27
import PackageTests.BuildDeps.InternalLibrary1.Check
import PackageTests.BuildDeps.InternalLibrary2.Check
import PackageTests.BuildDeps.InternalLibrary3.Check
import PackageTests.BuildDeps.InternalLibrary4.Check
tibbe's avatar
tibbe committed
28
29
30
31
import PackageTests.BuildDeps.SameDepsAllRound.Check
import PackageTests.BuildDeps.TargetSpecificDeps1.Check
import PackageTests.BuildDeps.TargetSpecificDeps2.Check
import PackageTests.BuildDeps.TargetSpecificDeps3.Check
ttuegel's avatar
ttuegel committed
32
import PackageTests.BuildTestSuiteDetailedV09.Check
33
import PackageTests.PackageTester (PackageSpec(..), compileSetup)
tibbe's avatar
tibbe committed
34
35
import PackageTests.PathsModule.Executable.Check
import PackageTests.PathsModule.Library.Check
tibbe's avatar
tibbe committed
36
import PackageTests.PreProcess.Check
tibbe's avatar
tibbe committed
37
import PackageTests.TemplateHaskell.Check
38
import PackageTests.CMain.Check
refold's avatar
refold committed
39
import PackageTests.EmptyLib.Check
ttuegel's avatar
ttuegel committed
40
import PackageTests.TestOptions.Check
ttuegel's avatar
ttuegel committed
41
import PackageTests.TestStanza.Check
42
import PackageTests.TestSuiteExeV10.Check
43
44
45
46

hunit :: TestName -> HUnit.Test -> Test
hunit name test = testGroup name $ hUnitTestToTests test

47
48
tests :: Version -> PackageSpec -> [Test]
tests version inplaceSpec =
49
    [ hunit "BuildDeps/SameDepsAllRound"
tibbe's avatar
tibbe committed
50
51
52
53
54
55
56
      PackageTests.BuildDeps.SameDepsAllRound.Check.suite
      -- The two following tests were disabled by Johan Tibell as
      -- they have been failing for a long time:
      -- , hunit "BuildDeps/GlobalBuildDepsNotAdditive1/"
      --   PackageTests.BuildDeps.GlobalBuildDepsNotAdditive1.Check.suite
      -- , hunit "BuildDeps/GlobalBuildDepsNotAdditive2/"
      --   PackageTests.BuildDeps.GlobalBuildDepsNotAdditive2.Check.suite
57
    , hunit "BuildDeps/InternalLibrary0"
58
      (PackageTests.BuildDeps.InternalLibrary0.Check.suite version)
tibbe's avatar
tibbe committed
59
    , hunit "PreProcess" PackageTests.PreProcess.Check.suite
tibbe's avatar
tibbe committed
60
    , hunit "TestStanza" PackageTests.TestStanza.Check.suite
tibbe's avatar
tibbe committed
61
62
      -- ^ The Test stanza test will eventually be required
      -- only for higher versions.
tibbe's avatar
tibbe committed
63
    , hunit "TestSuiteExeV10/Test" PackageTests.TestSuiteExeV10.Check.checkTest
tibbe's avatar
tibbe committed
64
    , hunit "TestSuiteExeV10/TestWithHpc"
tibbe's avatar
tibbe committed
65
      PackageTests.TestSuiteExeV10.Check.checkTestWithHpc
tibbe's avatar
tibbe committed
66
    , hunit "TestOptions" PackageTests.TestOptions.Check.suite
67
    , hunit "BenchmarkStanza" PackageTests.BenchmarkStanza.Check.suite
tibbe's avatar
tibbe committed
68
69
70
      -- ^ The benchmark stanza test will eventually be required
      -- only for higher versions.
    , hunit "BenchmarkExeV10/Test"
71
      PackageTests.BenchmarkExeV10.Check.checkBenchmark
tibbe's avatar
tibbe committed
72
73
74
75
76
77
78
79
    , hunit "BenchmarkOptions" PackageTests.BenchmarkOptions.Check.suite
    , hunit "TemplateHaskell/profiling"
      PackageTests.TemplateHaskell.Check.profiling
    , hunit "TemplateHaskell/dynamic"
      PackageTests.TemplateHaskell.Check.dynamic
    , hunit "PathsModule/Executable"
      PackageTests.PathsModule.Executable.Check.suite
    , hunit "PathsModule/Library" PackageTests.PathsModule.Library.Check.suite
refold's avatar
refold committed
80
81
    , hunit "EmptyLib/emptyLib"
      PackageTests.EmptyLib.Check.emptyLib
ttuegel's avatar
ttuegel committed
82
    , hunit "BuildTestSuiteDetailedV09"
83
      $ PackageTests.BuildTestSuiteDetailedV09.Check.suite inplaceSpec
84
85
    ] ++
    -- These tests are only required to pass on cabal version >= 1.7
86
87
    (if version >= Version [1, 7] []
     then [ hunit "BuildDeps/TargetSpecificDeps1"
tibbe's avatar
tibbe committed
88
            PackageTests.BuildDeps.TargetSpecificDeps1.Check.suite
89
          , hunit "BuildDeps/TargetSpecificDeps2"
tibbe's avatar
tibbe committed
90
            PackageTests.BuildDeps.TargetSpecificDeps2.Check.suite
91
          , hunit "BuildDeps/TargetSpecificDeps3"
tibbe's avatar
tibbe committed
92
            PackageTests.BuildDeps.TargetSpecificDeps3.Check.suite
93
          , hunit "BuildDeps/InternalLibrary1"
tibbe's avatar
tibbe committed
94
            PackageTests.BuildDeps.InternalLibrary1.Check.suite
95
          , hunit "BuildDeps/InternalLibrary2"
tibbe's avatar
tibbe committed
96
            PackageTests.BuildDeps.InternalLibrary2.Check.suite
97
          , hunit "BuildDeps/InternalLibrary3"
tibbe's avatar
tibbe committed
98
            PackageTests.BuildDeps.InternalLibrary3.Check.suite
99
          , hunit "BuildDeps/InternalLibrary4"
tibbe's avatar
tibbe committed
100
            PackageTests.BuildDeps.InternalLibrary4.Check.suite
101
102
          , hunit "PackageTests/CMain"
            PackageTests.CMain.Check.checkBuild
tibbe's avatar
tibbe committed
103
104
          ]
     else [])
105

106
main :: IO ()
107
main = do
108
109
110
111
112
113
114
115
    wd <- getCurrentDirectory
    let dbFile = wd </> "dist/package.conf.inplace"
        inplaceSpec = PackageSpec
            { directory = []
            , configOpts = [ "--package-db=" ++ dbFile
                           , "--constraint=Cabal == " ++ display cabalVersion
                           ]
            }
tibbe's avatar
tibbe committed
116
117
    putStrLn $ "Cabal test suite - testing cabal version " ++
        display cabalVersion
118
    setCurrentDirectory "tests"
119
120
    -- Create a shared Setup executable to speed up Simple tests
    compileSetup "."
121
    defaultMain (tests cabalVersion inplaceSpec)