Commit c1f455f1 authored by ttuegel's avatar ttuegel
Browse files

Added unit test for test options.

parent eadde7a2
......@@ -142,6 +142,7 @@ test-suite unit-tests
PackageTests.BuildDeps.TargetSpecificDeps2.Check,
PackageTests.BuildDeps.TargetSpecificDeps3.Check,
PackageTests.BuildDeps.SameDepsAllRound.Check,
PackageTests.TestOptions.Check,
PackageTests.TestStanza.Check,
PackageTests.TestSuiteExeV10.Check,
PackageTests.PackageTester
......
......@@ -104,9 +104,9 @@ cabal_install spec = do
record spec res
return res
cabal_test :: PackageSpec -> IO Result
cabal_test spec = do
res <- cabal spec ["test"]
cabal_test :: PackageSpec -> [String] -> IO Result
cabal_test spec extraArgs = do
res <- cabal spec $ "test" : extraArgs
let r = recordRun res TestSuccess nullResult
record spec r
return r
......
module PackageTests.TestOptions.Check where
import Test.HUnit
import System.FilePath
import PackageTests.PackageTester
suite :: Test
suite = TestCase $ do
let directory = "PackageTests" </> "TestOptions"
pdFile = directory </> "TestOptions" <.> "cabal"
spec = PackageSpec directory ["--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 "
++ "test executable with \"--test-options\""
assertEqual message True $ successful result
result' <- cabal_test spec [ "--test-option=1"
, "--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'
import Distribution.Simple
main = defaultMain
name: TestOptions
version: 0.1
license: BSD3
author: Thomas Tuegel
stability: stable
category: PackageTests
build-type: Simple
cabal-version: >= 1.9.2
description:
Check that Cabal passes the correct test options to test suites.
executable dummy
main-is: test-TestOptions.hs
build-depends: base
test-suite test-TestOptions
main-is: test-TestOptions.hs
type: exitcode-stdio-1.0
build-depends: base
module Main where
import System.Environment ( getArgs )
import System.Exit ( exitFailure, exitSuccess )
main :: IO ()
main = do
args <- getArgs
if args == ["1", "2", "3"]
then exitSuccess
else putStrLn ("Got: " ++ show args) >> exitFailure
......@@ -20,7 +20,7 @@ checkTest cabalVersion = TestCase $ do
buildResult <- cabal_build spec
let buildMessage = "\'setup build\' should succeed"
assertEqual buildMessage True $ successful buildResult
testResult <- cabal_test spec
testResult <- cabal_test spec []
let testMessage = "\'setup test\' should succeed"
assertEqual testMessage True $ successful testResult
......@@ -32,7 +32,7 @@ checkTestWithHpc cabalVersion = TestCase $ do
buildResult <- cabal_build spec
let buildMessage = "\'setup build\' should succeed"
assertEqual buildMessage True $ successful buildResult
testResult <- cabal_test spec
testResult <- cabal_test spec []
let testMessage = "\'setup test\' should succeed"
assertEqual testMessage True $ successful testResult
let dummy = emptyTestSuite { testName = "test-Foo" }
......
......@@ -22,6 +22,7 @@ import PackageTests.BuildDeps.InternalLibrary1.Check
import PackageTests.BuildDeps.InternalLibrary2.Check
import PackageTests.BuildDeps.InternalLibrary3.Check
import PackageTests.BuildDeps.InternalLibrary4.Check
import PackageTests.TestOptions.Check
import PackageTests.TestStanza.Check
import PackageTests.TestSuiteExeV10.Check
import Distribution.Text (display)
......@@ -44,7 +45,8 @@ tests cabalVersion = [
hunit "PackageTests/TestSuiteExeV10/Test"
(PackageTests.TestSuiteExeV10.Check.checkTest cabalVersion),
hunit "PackageTests/TestSuiteExeV10/TestWithHpc"
(PackageTests.TestSuiteExeV10.Check.checkTestWithHpc cabalVersion)
(PackageTests.TestSuiteExeV10.Check.checkTestWithHpc cabalVersion),
hunit "PackageTests/TestOptions" PackageTests.TestOptions.Check.suite
] ++
-- These tests are only required to pass on cabal version >= 1.7
(if cabalVersion >= Version [1, 7] []
......
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