-
Notifications
You must be signed in to change notification settings - Fork 691
/
Check.hs
47 lines (43 loc) · 1.84 KB
/
Check.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
module PackageTests.TestSuiteExeV10.Check
( checkTest
, checkTestWithHpc
) where
import Distribution.PackageDescription ( TestSuite(..), emptyTestSuite )
import Distribution.Simple.Hpc
import Distribution.Version
import Test.HUnit
import System.Directory
import System.FilePath
import PackageTests.PackageTester
dir :: FilePath
dir = "PackageTests" </> "TestSuiteExeV10"
checkTest :: Version -> Test
checkTest cabalVersion = TestCase $ do
let spec = PackageSpec dir ["--enable-tests"]
buildResult <- cabal_build spec
let buildMessage = "\'setup build\' should succeed"
assertEqual buildMessage True $ successful buildResult
testResult <- cabal_test spec []
let testMessage = "\'setup test\' should succeed"
assertEqual testMessage True $ successful testResult
checkTestWithHpc :: Version -> Test
checkTestWithHpc cabalVersion = TestCase $ do
let spec = PackageSpec dir [ "--enable-tests"
, "--enable-library-coverage"
]
buildResult <- cabal_build spec
let buildMessage = "\'setup build\' should succeed"
assertEqual buildMessage True $ successful buildResult
testResult <- cabal_test spec []
let testMessage = "\'setup test\' should succeed"
assertEqual testMessage True $ successful testResult
let dummy = emptyTestSuite { testName = "test-Foo" }
tixFile = tixFilePath (dir </> "dist") $ testName dummy
tixFileMessage = ".tix file should exist"
markupDir = htmlDir (dir </> "dist") $ testName dummy
markupFile = markupDir </> "hpc_index" <.> "html"
markupFileMessage = "HPC markup file should exist"
tixFileExists <- doesFileExist tixFile
assertEqual tixFileMessage True tixFileExists
markupFileExists <- doesFileExist markupFile
assertEqual markupFileMessage True markupFileExists