Commit a29b6d38 authored by tibbe's avatar tibbe
Browse files

Fix remaining warnings in the test suite

parent 58250e4f
......@@ -26,7 +26,6 @@ import PackageTests.BuildDeps.InternalLibrary3.Check
import PackageTests.BuildDeps.InternalLibrary4.Check
import PackageTests.BuildDeps.SameDepsAllRound.Check
import PackageTests.BuildDeps.TargetSpecificDeps1.Check
import PackageTests.BuildDeps.TargetSpecificDeps1.Check
import PackageTests.BuildDeps.TargetSpecificDeps2.Check
import PackageTests.BuildDeps.TargetSpecificDeps3.Check
import PackageTests.PathsModule.Executable.Check
......@@ -40,7 +39,7 @@ hunit :: TestName -> HUnit.Test -> Test
hunit name test = testGroup name $ hUnitTestToTests test
tests :: Version -> [Test]
tests cabalVersion =
tests version =
[ hunit "BuildDeps/SameDepsAllRound"
PackageTests.BuildDeps.SameDepsAllRound.Check.suite
-- The two following tests were disabled by Johan Tibell as
......@@ -50,7 +49,7 @@ tests cabalVersion =
-- , hunit "BuildDeps/GlobalBuildDepsNotAdditive2/"
-- PackageTests.BuildDeps.GlobalBuildDepsNotAdditive2.Check.suite
, hunit "BuildDeps/InternalLibrary0"
(PackageTests.BuildDeps.InternalLibrary0.Check.suite cabalVersion)
(PackageTests.BuildDeps.InternalLibrary0.Check.suite version)
, hunit "TestStanza" PackageTests.TestStanza.Check.suite
-- ^ The Test stanza test will eventually be required
-- only for higher versions.
......@@ -58,12 +57,11 @@ tests cabalVersion =
, hunit "TestSuiteExeV10/TestWithHpc"
PackageTests.TestSuiteExeV10.Check.checkTestWithHpc
, hunit "TestOptions" PackageTests.TestOptions.Check.suite
, hunit "BenchmarkStanza"
(PackageTests.BenchmarkStanza.Check.suite cabalVersion)
, hunit "BenchmarkStanza" PackageTests.BenchmarkStanza.Check.suite
-- ^ The benchmark stanza test will eventually be required
-- only for higher versions.
, hunit "BenchmarkExeV10/Test"
(PackageTests.BenchmarkExeV10.Check.checkBenchmark cabalVersion)
PackageTests.BenchmarkExeV10.Check.checkBenchmark
, hunit "BenchmarkOptions" PackageTests.BenchmarkOptions.Check.suite
, hunit "TemplateHaskell/profiling"
PackageTests.TemplateHaskell.Check.profiling
......@@ -74,24 +72,25 @@ tests cabalVersion =
, hunit "PathsModule/Library" PackageTests.PathsModule.Library.Check.suite
] ++
-- These tests are only required to pass on cabal version >= 1.7
(if cabalVersion >= Version [1, 7] []
then [ hunit "BuildDeps/TargetSpecificDeps1/"
(if version >= Version [1, 7] []
then [ hunit "BuildDeps/TargetSpecificDeps1"
PackageTests.BuildDeps.TargetSpecificDeps1.Check.suite
, hunit "BuildDeps/TargetSpecificDeps2/"
, hunit "BuildDeps/TargetSpecificDeps2"
PackageTests.BuildDeps.TargetSpecificDeps2.Check.suite
, hunit "BuildDeps/TargetSpecificDeps3/"
, hunit "BuildDeps/TargetSpecificDeps3"
PackageTests.BuildDeps.TargetSpecificDeps3.Check.suite
, hunit "BuildDeps/InternalLibrary1/"
, hunit "BuildDeps/InternalLibrary1"
PackageTests.BuildDeps.InternalLibrary1.Check.suite
, hunit "BuildDeps/InternalLibrary2/"
, hunit "BuildDeps/InternalLibrary2"
PackageTests.BuildDeps.InternalLibrary2.Check.suite
, hunit "BuildDeps/InternalLibrary3/"
, hunit "BuildDeps/InternalLibrary3"
PackageTests.BuildDeps.InternalLibrary3.Check.suite
, hunit "BuildDeps/InternalLibrary4/"
, hunit "BuildDeps/InternalLibrary4"
PackageTests.BuildDeps.InternalLibrary4.Check.suite
]
else [])
main :: IO ()
main = do
putStrLn $ "Cabal test suite - testing cabal version " ++
display cabalVersion
......
......@@ -2,19 +2,15 @@ module PackageTests.BenchmarkExeV10.Check
( checkBenchmark
) where
import Distribution.PackageDescription ( Benchmark(..), emptyBenchmark )
import Distribution.Simple.Hpc
import Distribution.Version
import Test.HUnit
import System.Directory
import System.FilePath
import PackageTests.PackageTester
import System.FilePath
import Test.HUnit
dir :: FilePath
dir = "PackageTests" </> "BenchmarkExeV10"
checkBenchmark :: Version -> Test
checkBenchmark cabalVersion = TestCase $ do
checkBenchmark :: Test
checkBenchmark = TestCase $ do
let spec = PackageSpec dir ["--enable-benchmarks"]
buildResult <- cabal_build spec
assertBuildSucceeded buildResult
module PackageTests.BenchmarkOptions.Check where
import Test.HUnit
import System.FilePath
import PackageTests.PackageTester
import System.FilePath
import Test.HUnit
suite :: Test
suite = TestCase $ do
let directory = "PackageTests" </> "BenchmarkOptions"
pdFile = directory </> "BenchmarkOptions" <.> "cabal"
spec = PackageSpec directory ["--enable-benchmarks"]
let spec = PackageSpec ("PackageTests" </> "BenchmarkOptions")
["--enable-benchmarks"]
_ <- cabal_build spec
result <- cabal_bench spec ["--benchmark-options=1 2 3"]
let message = "\"cabal bench\" did not pass the correct options to the "
......@@ -18,6 +17,6 @@ suite = TestCase $ do
, "--benchmark-option=2"
, "--benchmark-option=3"
]
let message = "\"cabal bench\" did not pass the correct options to the "
++ "benchmark executable with \"--benchmark-option\""
assertEqual message True $ successful result'
let message' = "\"cabal bench\" did not pass the correct options to the "
++ "benchmark executable with \"--benchmark-option\""
assertEqual message' True $ successful result'
......@@ -3,41 +3,33 @@ module PackageTests.BenchmarkStanza.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(..) )
( PackageName(..), Dependency(..) )
import Distribution.PackageDescription
( PackageDescription(..), BuildInfo(..), Benchmark(..), Library(..)
( PackageDescription(..), BuildInfo(..), Benchmark(..)
, BenchmarkInterface(..)
, TestType(..), emptyPackageDescription, emptyBuildInfo, emptyLibrary
, emptyBenchmark, BuildType(..) )
, emptyBuildInfo
, emptyBenchmark )
import Distribution.Verbosity (silent)
import Distribution.License (License(..))
import Distribution.ModuleName (fromString)
import Distribution.System (buildPlatform)
import Distribution.Compiler
( CompilerId(..), CompilerFlavor(..) )
import Distribution.Text
suite :: Version -> Test
suite cabalVersion = TestCase $ do
let directory = "PackageTests" </> "BenchmarkStanza"
pdFile = directory </> "my" <.> "cabal"
spec = PackageSpec directory []
suite :: Test
suite = TestCase $ do
let dir = "PackageTests" </> "BenchmarkStanza"
pdFile = dir </> "my" <.> "cabal"
spec = PackageSpec dir []
result <- cabal_configure spec
let message = "cabal configure should recognize benchmark section"
test = "unknown section type"
`isInfixOf`
(intercalate " " $ lines $ outputText result)
assertEqual message False test
assertOutputDoesNotContain "unknown section type" result
genPD <- readPackageDescription silent pdFile
let compiler = CompilerId GHC $ Version [6, 12, 2] []
anyV = intersectVersionRanges anyVersion anyVersion
anticipatedBenchmark = emptyBenchmark
{ benchmarkName = "dummy"
, benchmarkInterface = BenchmarkExeV10 (Version [1,0] []) "dummy.hs"
......
module PackageTests.BuildDeps.InternalLibrary0.Check where
import Test.HUnit
import PackageTests.PackageTester
import Control.Monad
import System.FilePath
import Data.Version
import Data.List (isInfixOf, intercalate)
import Control.Exception
import PackageTests.PackageTester
import Prelude hiding (catch)
import System.FilePath
import Test.HUnit
suite :: Version -> Test
......
module PackageTests.BuildDeps.InternalLibrary1.Check where
import Test.HUnit
import PackageTests.PackageTester
import System.FilePath
import Control.Exception
import Prelude hiding (catch)
import System.FilePath
import Test.HUnit
suite :: Test
......
module PackageTests.BuildDeps.InternalLibrary2.Check where
import Test.HUnit
import PackageTests.PackageTester
import System.FilePath
import qualified Data.ByteString.Char8 as C
import Control.Exception
import PackageTests.PackageTester
import Prelude hiding (catch)
import System.FilePath
import Test.HUnit
suite :: Test
......
module PackageTests.BuildDeps.InternalLibrary3.Check where
import Test.HUnit
import PackageTests.PackageTester
import System.FilePath
import qualified Data.ByteString.Char8 as C
import Control.Exception
import PackageTests.PackageTester
import Prelude hiding (catch)
import System.FilePath
import Test.HUnit
suite :: Test
......
module PackageTests.BuildDeps.InternalLibrary4.Check where
import Test.HUnit
import PackageTests.PackageTester
import System.FilePath
import qualified Data.ByteString.Char8 as C
import Control.Exception
import PackageTests.PackageTester
import Prelude hiding (catch)
import System.FilePath
import Test.HUnit
suite :: Test
......
......@@ -14,7 +14,8 @@ module PackageTests.PackageTester (
assertBuildFailed,
assertTestSucceeded,
assertInstallSucceeded,
assertOutputContains
assertOutputContains,
assertOutputDoesNotContain
) where
import qualified Control.Exception.Extensible as E
......@@ -220,6 +221,14 @@ assertOutputContains needle result =
"in output: " ++ output
where output = outputText result
assertOutputDoesNotContain :: String -> Result -> Assertion
assertOutputDoesNotContain needle result =
when (needle `isInfixOf` (intercalate " " $ lines output)) $
assertFailure $
"unexpected: " ++ needle ++
" in output: " ++ output
where output = outputText result
------------------------------------------------------------------------
-- Finding ghc and related tools
--
......
module PackageTests.PathsModule.Executable.Check (suite) where
import Distribution.Version
import PackageTests.PackageTester (PackageSpec(..), assertBuildSucceeded,
cabal_build)
import PackageTests.PackageTester
(PackageSpec(..), assertBuildSucceeded, cabal_build)
import System.FilePath
import Test.HUnit
......
module PackageTests.PathsModule.Library.Check (suite) where
import Distribution.Version
import PackageTests.PackageTester (PackageSpec(..), assertBuildSucceeded,
cabal_build)
import PackageTests.PackageTester
(PackageSpec(..), assertBuildSucceeded, cabal_build)
import System.FilePath
import Test.HUnit
......
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
import System.FilePath
import Test.HUnit
profiling :: Test
profiling = TestCase $ do
......
module PackageTests.TestOptions.Check where
import Test.HUnit
import System.FilePath
import PackageTests.PackageTester
import System.FilePath
import Test.HUnit
suite :: Test
suite = TestCase $ do
let directory = "PackageTests" </> "TestOptions"
pdFile = directory </> "TestOptions" <.> "cabal"
spec = PackageSpec directory ["--enable-tests"]
let spec = PackageSpec ("PackageTests" </> "TestOptions")
["--enable-tests"]
_ <- cabal_build spec
result <- cabal_test spec ["--test-options=1 2 3"]
let message = "\"cabal test\" did not pass the correct options to the "
......@@ -18,6 +17,6 @@ suite = TestCase $ do
, "--test-option=2"
, "--test-option=3"
]
let message = "\"cabal test\" did not pass the correct options to the "
++ "test executable with \"--test-option\""
assertEqual message True $ successful result'
let message' = "\"cabal test\" did not pass the correct options to the "
++ "test executable with \"--test-option\""
assertEqual message' True $ successful result'
......@@ -3,39 +3,28 @@ module PackageTests.TestStanza.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.Parse (readPackageDescription)
import Distribution.PackageDescription.Configuration
( finalizePackageDescription )
import Distribution.Package
( PackageName(..), Dependency(..) )
(finalizePackageDescription)
import Distribution.Package (PackageName(..), Dependency(..))
import Distribution.PackageDescription
( PackageDescription(..), BuildInfo(..), TestSuite(..)
, TestSuiteInterface(..), emptyBuildInfo, emptyTestSuite )
( PackageDescription(..), BuildInfo(..), TestSuite(..)
, TestSuiteInterface(..), emptyBuildInfo, emptyTestSuite)
import Distribution.Verbosity (silent)
import Distribution.License (License(..))
import Distribution.ModuleName (fromString)
import Distribution.System (buildPlatform)
import Distribution.Compiler
( CompilerId(..), CompilerFlavor(..) )
import Distribution.Compiler (CompilerId(..), CompilerFlavor(..))
import Distribution.Text
suite :: Test
suite = TestCase $ do
let directory = "PackageTests" </> "TestStanza"
pdFile = directory </> "my" <.> "cabal"
spec = PackageSpec directory []
let dir = "PackageTests" </> "TestStanza"
pdFile = dir </> "my" <.> "cabal"
spec = PackageSpec dir []
result <- cabal_configure spec
let message = "cabal configure should recognize test section"
test = "unknown section type"
`isInfixOf`
(intercalate " " $ lines $ outputText result)
assertEqual message False test
assertOutputDoesNotContain "unknown section type" result
genPD <- readPackageDescription silent pdFile
let compiler = CompilerId GHC $ Version [6, 12, 2] []
anyV = intersectVersionRanges anyVersion anyVersion
anticipatedTestSuite = emptyTestSuite
{ testName = "dummy"
, testInterface = TestSuiteExeV10 (Version [1,0] []) "dummy.hs"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment