Commit a1d9e88d authored by Benno Fünfstück's avatar Benno Fünfstück Committed by Edward Z. Yang
Browse files

Fix #4270: add regression test

parent e76c4820
module Lib where
foo :: Bool
foo = True
name: T4270
version: 0.1
cabal-version: >= 1.2
license: BSD3
author: Benno Fünfstück
stability: stable
category: PackageTests
build-type: Simple
cabal-version: >= 1.9.2
description: Check type detailed-0.9 test suites with dynamic linking.
library
exposed-modules: Lib
build-depends: base
test-suite test
type: detailed-0.9
test-module: Test
build-depends: base, Cabal, T4270
module Test where
import Lib
import Distribution.TestSuite
tests :: IO [Test]
tests = return [Test bar]
where
bar = TestInstance
{ run = return $ Finished run
, name = "test"
, tags = []
, options = []
, setOption = \_ _ -> Right bar
}
run = if foo then Pass else Fail "should pass"
import Test.Cabal.Prelude
-- Test if detailed-0.9 builds correctly and runs
-- when linked dynamically
-- See https://github.com/haskell/cabal/issues/4270
main = setupAndCabalTest $ do
skipUnless =<< hasSharedLibraries
skipUnless =<< hasCabalShared
setup_build ["--enable-tests", "--enable-executable-dynamic"]
setup "test" []
......@@ -283,6 +283,7 @@ runTestM m = do
testScriptEnv = senv,
testSetupPath = dist_dir </> "setup" </> "setup",
testSkipSetupTests = argSkipSetupTests (testCommonArgs args),
testHaveCabalShared = withSharedLib lbi,
testEnvironment =
-- Try to avoid Unicode output
[ ("LC_ALL", Just "C")
......@@ -368,6 +369,10 @@ data TestEnv = TestEnv
, testSetupPath :: FilePath
-- | Skip Setup tests?
, testSkipSetupTests :: Bool
-- | Do we have shared libraries for the Cabal-under-tests?
-- This is used for example to determine whether we can build
-- detailed-0.9 tests dynamically, since they link against Cabal-under-test.
, testHaveCabalShared :: Bool
-- CHANGING:
......
......@@ -576,6 +576,16 @@ hasSharedLibraries = do
shared_libs_were_removed <- ghcVersionIs (>= mkVersion [7,8])
return (not (buildOS == Windows && shared_libs_were_removed))
-- | Check if the GHC that is used for compiling package tests has
-- a shared library of the cabal library under test in its database.
--
-- An example where this is needed is if you want to dynamically link
-- detailed-0.9 test suites, since those depend on the Cabal library unde rtest.
hasCabalShared :: TestM Bool
hasCabalShared = do
env <- getTestEnv
return (testHaveCabalShared env)
ghcVersionIs :: WithCallStack ((Version -> Bool) -> TestM Bool)
ghcVersionIs f = do
ghc_program <- requireProgramM ghcProgram
......
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