Skip to content

Commit

Permalink
add deadlock test for detailed-0.9 test suites
Browse files Browse the repository at this point in the history
  • Loading branch information
ttuegel committed Mar 29, 2015
1 parent 54499ef commit 8dc0a8d
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Cabal/Cabal.cabal
Expand Up @@ -114,7 +114,10 @@ extra-source-files:
tests/PackageTests/TestStanza/my.cabal
tests/PackageTests/TestSuiteTests/ExeV10/Foo.hs
tests/PackageTests/TestSuiteTests/ExeV10/my.cabal
tests/PackageTests/TestSuiteExeV10/tests/test-Foo.hs
tests/PackageTests/TestSuiteTests/ExeV10/tests/test-Foo.hs
tests/PackageTests/TestSuiteTests/LibV09/LibV09.cabal
tests/PackageTests/TestSuiteTests/LibV09/Lib.hs
tests/PackageTests/TestSuiteTests/LibV09/Deadlock.hs
tests/Setup.hs
tests/hackage/check.sh
tests/hackage/download.sh
Expand Down Expand Up @@ -303,6 +306,7 @@ test-suite package-tests
PackageTests.TestOptions.Check
PackageTests.TestStanza.Check
PackageTests.TestSuiteTests.ExeV10.Check
PackageTests.TestSuiteTests.LibV09.Check
hs-source-dirs: tests
build-depends:
base,
Expand Down
3 changes: 3 additions & 0 deletions Cabal/tests/PackageTests.hs
Expand Up @@ -33,6 +33,7 @@ import PackageTests.Haddock.Check
import PackageTests.TestOptions.Check
import PackageTests.TestStanza.Check
import PackageTests.TestSuiteTests.ExeV10.Check
import PackageTests.TestSuiteTests.LibV09.Check
import PackageTests.OrderFlags.Check
import PackageTests.ReexportedModules.Check

Expand Down Expand Up @@ -75,6 +76,8 @@ tests version inplaceSpec ghcPath ghcPkgPath =
, testGroup "TestSuiteTests"
[ testGroup "ExeV10"
(PackageTests.TestSuiteTests.ExeV10.Check.checks ghcPath)
, testGroup "LibV09"
(PackageTests.TestSuiteTests.LibV09.Check.checks inplaceSpec ghcPath)
]
, testCase "TestOptions" (PackageTests.TestOptions.Check.suite ghcPath)
, testCase "BenchmarkStanza" (PackageTests.BenchmarkStanza.Check.suite ghcPath)
Expand Down
7 changes: 7 additions & 0 deletions Cabal/tests/PackageTests/PackageTester.hs
Expand Up @@ -24,6 +24,7 @@ module PackageTests.PackageTester
, assertBuildFailed
, assertHaddockSucceeded
, assertTestSucceeded
, assertTestFailed
, assertInstallSucceeded
, assertOutputContains
, assertOutputDoesNotContain
Expand Down Expand Up @@ -272,6 +273,12 @@ assertTestSucceeded result = unless (successful result) $
"expected: \'setup test\' should succeed\n" ++
" output: " ++ outputText result

assertTestFailed :: Result -> Assertion
assertTestFailed result = when (successful result) $
assertFailure $
"expected: \'setup test\' should fail\n" ++
" output: " ++ outputText result

assertInstallSucceeded :: Result -> Assertion
assertInstallSucceeded result = unless (successful result) $
assertFailure $
Expand Down
39 changes: 39 additions & 0 deletions Cabal/tests/PackageTests/TestSuiteTests/LibV09/Check.hs
@@ -0,0 +1,39 @@
module PackageTests.TestSuiteTests.LibV09.Check (checks) where

import Test.Tasty
import Test.Tasty.HUnit
import System.FilePath ((</>))

import PackageTests.PackageTester

dir :: FilePath
dir = "PackageTests" </> "TestSuiteTests" </> "LibV09"

checks :: PackageSpec -> FilePath -> [TestTree]
checks inplaceSpec ghcPath =
[ testCase "Build" $ checkBuild inplaceSpec ghcPath
, localOption (mkTimeout $ 10 * 10 ^ (6 :: Int))
$ testCase "Deadlock" $ checkDeadlock inplaceSpec ghcPath
]

checkBuild :: PackageSpec -> FilePath -> Assertion
checkBuild inplaceSpec ghcPath = do
let spec = inplaceSpec
{ directory = dir
, distPref = Just $ "dist-Build"
, configOpts = "--enable-tests" : configOpts inplaceSpec
}
buildResult <- cabal_build spec ghcPath
assertBuildSucceeded buildResult

checkDeadlock :: PackageSpec -> FilePath -> Assertion
checkDeadlock inplaceSpec ghcPath = do
let spec = inplaceSpec
{ directory = dir
, distPref = Just $ "dist-Test"
, configOpts = "--enable-tests" : configOpts inplaceSpec
}
buildResult <- cabal_build spec ghcPath
assertBuildSucceeded buildResult
testResult <- cabal_test spec [] [] ghcPath
assertTestFailed testResult
11 changes: 11 additions & 0 deletions Cabal/tests/PackageTests/TestSuiteTests/LibV09/Lib.hs
@@ -0,0 +1,11 @@
module Lib where

import Distribution.TestSuite

nullt x = Test $ TestInstance
{ run = return $ Finished (Fail "no reason")
, name = "test " ++ show x
, tags = []
, options = []
, setOption = \_ _-> Left "No Options"
}
21 changes: 21 additions & 0 deletions Cabal/tests/PackageTests/TestSuiteTests/LibV09/LibV09.cabal
@@ -0,0 +1,21 @@
name: LibV09
version: 0.1
cabal-version: >= 1.2
license: BSD3
author: Thomas Tuegel
stability: stable
category: PackageTests
build-type: Simple
cabal-version: >= 1.9.2

description: Check type detailed-0.9 test suites.

library
exposed-modules: Lib
build-depends: base, Cabal

test-suite LibV09-Deadlock
type: detailed-0.9
hs-source-dirs: tests
test-module: Deadlock
build-depends: base, Cabal, LibV09
@@ -0,0 +1,8 @@
module Deadlock where

import Distribution.TestSuite

import Lib

tests :: IO [Test]
tests = return [nullt x | x <- [1 .. 550]]

0 comments on commit 8dc0a8d

Please sign in to comment.