PackageTests.hs 4.98 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
14
import System.Directory (setCurrentDirectory)
import Test.Framework (Test, TestName, defaultMain, testGroup)
import Test.Framework.Providers.HUnit (hUnitTestToTests)
15
import qualified Test.HUnit as HUnit
tibbe's avatar
tibbe committed
16

tibbe's avatar
tibbe committed
17
import PackageTests.BenchmarkExeV10.Check
18
import PackageTests.BenchmarkOptions.Check
tibbe's avatar
tibbe committed
19
import PackageTests.BenchmarkStanza.Check
tibbe's avatar
tibbe committed
20
21
-- import PackageTests.BuildDeps.GlobalBuildDepsNotAdditive1.Check
-- import PackageTests.BuildDeps.GlobalBuildDepsNotAdditive2.Check
22
import PackageTests.BuildDeps.InternalLibrary0.Check
23
24
25
26
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
27
28
29
30
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
31
import PackageTests.BuildTestSuiteDetailedV09.Check
32
import PackageTests.PackageTester (compileSetup)
tibbe's avatar
tibbe committed
33
34
import PackageTests.PathsModule.Executable.Check
import PackageTests.PathsModule.Library.Check
tibbe's avatar
tibbe committed
35
import PackageTests.PreProcess.Check
tibbe's avatar
tibbe committed
36
import PackageTests.TemplateHaskell.Check
37
import PackageTests.CMain.Check
refold's avatar
refold committed
38
import PackageTests.EmptyLib.Check
ttuegel's avatar
ttuegel committed
39
import PackageTests.TestOptions.Check
ttuegel's avatar
ttuegel committed
40
import PackageTests.TestStanza.Check
41
import PackageTests.TestSuiteExeV10.Check
42
43
44
45
46

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

tests :: Version -> [Test]
47
tests version =
48
    [ hunit "BuildDeps/SameDepsAllRound"
tibbe's avatar
tibbe committed
49
50
51
52
53
54
55
      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
56
    , hunit "BuildDeps/InternalLibrary0"
57
      (PackageTests.BuildDeps.InternalLibrary0.Check.suite version)
tibbe's avatar
tibbe committed
58
    , hunit "PreProcess" PackageTests.PreProcess.Check.suite
tibbe's avatar
tibbe committed
59
    , hunit "TestStanza" PackageTests.TestStanza.Check.suite
tibbe's avatar
tibbe committed
60
61
      -- ^ The Test stanza test will eventually be required
      -- only for higher versions.
tibbe's avatar
tibbe committed
62
    , hunit "TestSuiteExeV10/Test" PackageTests.TestSuiteExeV10.Check.checkTest
tibbe's avatar
tibbe committed
63
    , hunit "TestSuiteExeV10/TestWithHpc"
tibbe's avatar
tibbe committed
64
      PackageTests.TestSuiteExeV10.Check.checkTestWithHpc
tibbe's avatar
tibbe committed
65
    , hunit "TestOptions" PackageTests.TestOptions.Check.suite
66
    , hunit "BenchmarkStanza" PackageTests.BenchmarkStanza.Check.suite
tibbe's avatar
tibbe committed
67
68
69
      -- ^ The benchmark stanza test will eventually be required
      -- only for higher versions.
    , hunit "BenchmarkExeV10/Test"
70
      PackageTests.BenchmarkExeV10.Check.checkBenchmark
tibbe's avatar
tibbe committed
71
72
73
74
75
76
77
78
    , 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
79
80
    , hunit "EmptyLib/emptyLib"
      PackageTests.EmptyLib.Check.emptyLib
ttuegel's avatar
ttuegel committed
81
82
    , hunit "BuildTestSuiteDetailedV09"
      PackageTests.BuildTestSuiteDetailedV09.Check.suite
83
84
    ] ++
    -- These tests are only required to pass on cabal version >= 1.7
85
86
    (if version >= Version [1, 7] []
     then [ hunit "BuildDeps/TargetSpecificDeps1"
tibbe's avatar
tibbe committed
87
            PackageTests.BuildDeps.TargetSpecificDeps1.Check.suite
88
          , hunit "BuildDeps/TargetSpecificDeps2"
tibbe's avatar
tibbe committed
89
            PackageTests.BuildDeps.TargetSpecificDeps2.Check.suite
90
          , hunit "BuildDeps/TargetSpecificDeps3"
tibbe's avatar
tibbe committed
91
            PackageTests.BuildDeps.TargetSpecificDeps3.Check.suite
92
          , hunit "BuildDeps/InternalLibrary1"
tibbe's avatar
tibbe committed
93
            PackageTests.BuildDeps.InternalLibrary1.Check.suite
94
          , hunit "BuildDeps/InternalLibrary2"
tibbe's avatar
tibbe committed
95
            PackageTests.BuildDeps.InternalLibrary2.Check.suite
96
          , hunit "BuildDeps/InternalLibrary3"
tibbe's avatar
tibbe committed
97
            PackageTests.BuildDeps.InternalLibrary3.Check.suite
98
          , hunit "BuildDeps/InternalLibrary4"
tibbe's avatar
tibbe committed
99
            PackageTests.BuildDeps.InternalLibrary4.Check.suite
100
101
          , hunit "PackageTests/CMain"
            PackageTests.CMain.Check.checkBuild
tibbe's avatar
tibbe committed
102
103
          ]
     else [])
104

105
main :: IO ()
106
main = do
tibbe's avatar
tibbe committed
107
108
    putStrLn $ "Cabal test suite - testing cabal version " ++
        display cabalVersion
109
    setCurrentDirectory "tests"
110
111
    -- Create a shared Setup executable to speed up Simple tests
    compileSetup "."
112
    defaultMain (tests cabalVersion)