Commit 2d388c06 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Testing with GHC 7.0 and 7.2.



In the process, I refactored the test suite a bit to be more robust
and handle the --with-compiler more correctly in most cases.

One note: I turned off the HPC tests with the GHC and WITH_GHC
parameters don't match.  In principle this should work but there
is some sort of bug.  I don't plan on fixing the bug.
Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent 21943c54
......@@ -17,6 +17,7 @@ before_install:
- travis_retry sudo add-apt-repository -y ppa:hvr/ghc
- travis_retry sudo apt-get update
- travis_retry sudo apt-get install cabal-install-1.24 ghc-$GHCVER-prof ghc-$GHCVER-dyn happy
- travis_retry sudo apt-get install ghc-7.0.4-prof ghc-7.0.4-dyn ghc-7.2.2-prof ghc-7.2.2-dyn
- export PATH=$HOME/.cabal/bin:/opt/ghc/$GHCVER/bin:/opt/cabal/1.24/bin:$PATH
- git version
......@@ -48,6 +49,9 @@ script:
- ./dist/setup/setup build # this builds all libraries and executables (including tests/benchmarks)
- ./dist/setup/setup haddock # see https://github.com/haskell/cabal/issues/2198
- ./dist/setup/setup test --show-details=streaming --test-option=--hide-successes
# Redo the package tests with different versions of GHC
- CABAL_PACKAGETESTS_WITH_GHC=/opt/ghc/7.0.4/bin/ghc ./dist/setup/setup test package-tests --show-details=streaming
- CABAL_PACKAGETESTS_WITH_GHC=/opt/ghc/7.2.2/bin/ghc ./dist/setup/setup test package-tests --show-details=streaming
- cabal check
- cabal sdist # tests that a source-distribution can be generated
......
......@@ -136,8 +136,12 @@ configure verbosity hcPath hcPkgPath conf0 = do
haddockProgram' = haddockProgram {
programFindLocation = guessHaddockFromGhcPath ghcProg
}
hpcProgram' = hpcProgram {
programFindLocation = guessHpcFromGhcPath ghcProg
}
conf3 = addKnownProgram haddockProgram' $
addKnownProgram hsc2hsProgram' conf2
addKnownProgram hsc2hsProgram' $
addKnownProgram hpcProgram' conf2
languages <- Internal.getLanguages verbosity implInfo ghcProg
extensions0 <- Internal.getExtensions verbosity implInfo ghcProg
......@@ -260,6 +264,12 @@ guessHaddockFromGhcPath :: ConfiguredProgram
-> IO (Maybe (FilePath, [FilePath]))
guessHaddockFromGhcPath = guessToolFromGhcPath haddockProgram
guessHpcFromGhcPath :: ConfiguredProgram
-> Verbosity -> ProgramSearchPath
-> IO (Maybe (FilePath, [FilePath]))
guessHpcFromGhcPath = guessToolFromGhcPath hpcProgram
getGhcInfo :: Verbosity -> ConfiguredProgram -> IO [(String, String)]
getGhcInfo verbosity ghcProg = Internal.getGhcInfo verbosity implInfo ghcProg
where
......
-- The intention is that this will be the new unit test framework.
-- Please add any working tests here. This file should do nothing
-- but import tests from other modules.
--
-- Stephen Blackheath, 2009
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE PatternGuards #-}
-- This is the runner for the package-tests suite. The actual
-- tests are in in PackageTests.Tests
module Main where
......@@ -12,17 +12,14 @@ import PackageTests.Tests
import Distribution.Simple.Configure
( ConfigStateFileError(..), findDistPrefOrDefault, getConfigStateFile
, interpretPackageDbFlags )
import Distribution.Simple.Compiler (PackageDB(..), PackageDBStack)
, interpretPackageDbFlags, configCompilerEx )
import Distribution.Simple.Compiler (PackageDB(..), PackageDBStack, CompilerFlavor(GHC))
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..))
import Distribution.Simple.Program.Types (Program(..), programPath, programVersion)
import Distribution.Simple.Program.Builtin
( ghcProgram, ghcPkgProgram, haddockProgram )
import Distribution.Simple.Program.Db (requireProgram)
import Distribution.Simple.Program (defaultProgramConfiguration)
import Distribution.Simple.Setup (Flag(..), readPackageDbList, showPackageDbList)
import Distribution.Simple.Utils (cabalVersion)
import Distribution.Text (display, simpleParse)
import Distribution.Verbosity (normal, flagToVerbosity)
import Distribution.Text (display)
import Distribution.Verbosity (normal, flagToVerbosity, lessVerbose)
import Distribution.ReadE (readEOrFail)
import Control.Exception
......@@ -32,7 +29,6 @@ import System.Directory
import Test.Tasty
import Test.Tasty.Options
import Test.Tasty.Ingredients
import Data.Maybe
#if MIN_VERSION_base(4,6,0)
import System.Environment ( getExecutablePath )
......@@ -60,81 +56,133 @@ main = do
-- all of the necessary dependencies to make our Cabal package
-- well-formed.
--
-- We could have the user pass these all in as arguments (TODO: this
-- should be an option), but there's a more convenient way to get
-- this information: the *build configuration* that was used to
-- build the Cabal library (and this test suite) in the first place.
-- To do this, we need to find the 'dist' directory that was set as
-- the build directory for Cabal.
-- We could have the user pass these all in as arguments, but
-- there's a more convenient way to get this information: the *build
-- configuration* that was used to build the Cabal library (and this
-- test suite) in the first place. To do this, we need to find the
-- 'dist' directory that was set as the build directory for Cabal.
-- First, figure out the dist directory associated with this Cabal.
dist_dir :: FilePath <- guessDistDir
dist_dir <- guessDistDir
-- Might be bottom, if we can't figure it out. If you override
-- all the relevant parameters you might still succeed.
lbi <- getPersistBuildConfig_ (dist_dir </> "setup-config")
-- Next, attempt to read out the LBI. This may not work, in which
-- case we'll try to guess the correct parameters. This is ignored
-- if values are explicitly passed into the test suite.
mb_lbi <- getPersistBuildConfig_ (dist_dir </> "setup-config")
-- You need to run the test suite in the right directory, sorry.
test_dir <- getCurrentDirectory
-- This variable is modestly misnamed: this refers to the base
-- directory of Cabal (so, CHECKOUT_DIR/Cabal, not
-- CHECKOUT_DIR/Cabal/test).
cabal_dir <- getCurrentDirectory
-- Pull out the information we need from the LBI
-- TODO: The paths to GHC are configurable by command line, but you
-- have to be careful: some tests might depend on the Cabal library,
-- in which case you REALLY need to have built and installed Cabal
-- for the version that the test suite is being built against. The
-- easiest thing to do is make sure you built Cabal the same way as
-- you will run the tests.
let getExePathFromEnvOrLBI env_name prog = do
r <- lookupEnv env_name
case r of
Nothing -> do
(conf, _) <- requireProgram normal prog (withPrograms lbi)
return (programPath conf)
Just x -> return x
-- It is too much damn work to actually properly configure it
-- (Cabal will go off and probe GHC and we really aren't keen
-- on doing this every time we run the test suite.)
ghc_path <- getExePathFromEnvOrLBI "CABAL_PACKAGETESTS_GHC" ghcProgram
ghc_pkg_path <- getExePathFromEnvOrLBI "CABAL_PACKAGETESTS_GHC_PKG"
ghcPkgProgram
haddock_path <- getExePathFromEnvOrLBI "CABAL_PACKAGETESTS_HADDOCK"
haddockProgram
-- TODO: make this controllable by a flag. We do have a flag
-- parser but it's not called early enough for this verbosity...
verbosity <- maybe normal (readEOrFail flagToVerbosity)
`fmap` lookupEnv "VERBOSE"
with_ghc_path <- fromMaybe ghc_path
`fmap` lookupEnv "CABAL_PACKAGETESTS_WITH_GHC"
-------------------------------------------------------------------
-- SETTING UP GHC AND GHC-PKG
-------------------------------------------------------------------
ghc_version_env <- lookupEnv "CABAL_PACKAGETESTS_GHC_VERSION"
ghc_version <- case ghc_version_env of
Nothing -> do
(ghcConf, _) <- requireProgram normal ghcProgram (withPrograms lbi)
return (fromJust (programVersion ghcConf))
Just str ->
return (fromJust (simpleParse str))
-- NOTE: There are TWO configurations of GHC we have to manage
-- when running the test suite.
--
-- 1. The primary GHC is the one that was used to build the
-- copy of Cabal that we are testing. This configuration
-- can be pulled out of the LBI.
--
-- 2. The "with" GHC is the version of GHC we ask the Cabal
-- we are testing to use (i.e., using --with-compiler). Notice
-- that this does NOT have to match the version we compiled
-- the library with! (Not all tests will work in this situation,
-- however, since some need to link against the Cabal library.)
-- By default we use the same configuration as the one from the
-- LBI, but a user can override it to test against a different
-- version of GHC.
mb_ghc_path <- lookupEnv "CABAL_PACKAGETESTS_GHC"
mb_ghc_pkg_path <- lookupEnv "CABAL_PACKAGETESTS_GHC_PKG"
boot_programs <-
case (mb_ghc_path, mb_ghc_pkg_path) of
(Nothing, Nothing) | Just lbi <- mb_lbi -> do
putStrLn "Using configuration from LBI"
return (withPrograms lbi)
_ -> do
putStrLn "(Re)configuring test suite (ignoring LBI)"
(_comp, _compPlatform, programsConfig)
<- configCompilerEx
(Just GHC) mb_ghc_path mb_ghc_pkg_path
-- NB: if we accept full ConfigFlags parser then
-- should use (mkProgramsConfig cfg (configPrograms cfg))
-- instead.
defaultProgramConfiguration
(lessVerbose verbosity)
return programsConfig
with_ghc_version <- do
version <- programFindVersion ghcProgram normal with_ghc_path
case version of
Nothing -> error "Cannot determine version of GHC used for --with-ghc"
Just v -> return v
mb_with_ghc_path <- lookupEnv "CABAL_PACKAGETESTS_WITH_GHC"
mb_with_ghc_pkg_path <- lookupEnv "CABAL_PACKAGETESTS_WITH_GHC_PKG"
with_programs <-
case (mb_with_ghc_path, mb_with_ghc_path) of
(Nothing, Nothing) -> return boot_programs
_ -> do
putStrLn "Configuring test suite for --with-compiler"
(_comp, _compPlatform, with_programs)
<- configCompilerEx
(Just GHC) mb_with_ghc_path mb_with_ghc_pkg_path
defaultProgramConfiguration
(lessVerbose verbosity)
return with_programs
-- Package DBs are not guaranteed to be absolute, so make them so in
-- case a subprocess using the package DB needs a different CWD.
-------------------------------------------------------------------
-- SETTING UP THE DATABASE STACK
-------------------------------------------------------------------
-- Figure out what database stack to use. (This is the tricky bit,
-- because we need to have enough databases to make the just-built
-- Cabal package well-formed).
db_stack_env <- lookupEnv "CABAL_PACKAGETESTS_DB_STACK"
let packageDBStack0 = case db_stack_env of
Nothing -> withPackageDB lbi
Just str -> interpretPackageDbFlags True -- user install? why not.
(concatMap readPackageDbList
(splitSearchPath str))
Nothing ->
case mb_lbi of
Just lbi -> withPackageDB lbi
-- A wild guess!
Nothing -> interpretPackageDbFlags True []
-- Package DBs are not guaranteed to be absolute, so make them so in
-- case a subprocess using the package DB needs a different CWD.
packageDBStack1 <- mapM canonicalizePackageDB packageDBStack0
-- The packageDBStack is worth some commentary. The database
-- stack we extract from the LBI will contain enough package
-- databases to make the Cabal package well-formed. However,
-- it does not *contain* the inplace installed Cabal package.
-- So we need to add that to the stack.
let packageDBStack2
-- The LBI's database stack does *not* contain the inplace installed
-- Cabal package. So we need to add that to the stack.
let package_db_stack
= packageDBStack1 ++
[SpecificPackageDB
(dist_dir </> "package.conf.inplace")]
-- NB: It's possible that our database stack is broken (e.g.,
-- it's got a database for the wrong version of GHC, or it
-- doesn't have enough to let us build Cabal.) We'll notice
-- when we attempt to compile setup.
-- There is also is a parameter for the stack for --with-compiler,
-- since if GHC is a different version we need a different set of
-- databases. The default should actually be quite reasonable
-- as, unlike in the case of the GHC used to build Cabal, we don't
-- expect htere to be a Cabal available.
with_ghc_db_stack_env :: Maybe String
<- lookupEnv "CABAL_PACKAGETESTS_WITH_GHC_DB_STACK"
let withGhcDBStack0 :: PackageDBStack
withGhcDBStack0 =
interpretPackageDbFlags True
$ case with_ghc_db_stack_env of
Nothing -> []
Just str -> concatMap readPackageDbList (splitSearchPath str)
with_ghc_db_stack :: PackageDBStack
<- mapM canonicalizePackageDB withGhcDBStack0
-- THIS ISN'T EVEN MY FINAL FORM. The package database stack
-- controls where we install a package; specifically, the package is
-- installed to the top-most package on the stack (this makes the
......@@ -149,43 +197,35 @@ main = do
-- the install directories, so we don't clobber anything in the
-- default install paths. VERY IMPORTANT.
-- TODO: make this controllable by a flag
verbosity <- maybe normal (readEOrFail flagToVerbosity)
`fmap` lookupEnv "VERBOSE"
-- The inplaceDB is where the Cabal library was registered
-- in place (and is usable.) inplaceConfig is a convenient
-- set of flags to make sure we make it visible.
let suite = SuiteConfig
{ cabalDistPref = dist_dir
, ghcPath = ghc_path
, ghcVersion = ghc_version
, ghcPkgPath = ghc_pkg_path
, withGhcPath = with_ghc_path
, withGhcVersion = with_ghc_version
, packageDBStack = packageDBStack2
, bootProgramsConfig = boot_programs
, withProgramsConfig = with_programs
, packageDBStack = package_db_stack
, withGhcDBStack = with_ghc_db_stack
, suiteVerbosity = verbosity
, absoluteCWD = test_dir
, absoluteCWD = cabal_dir
}
putStrLn $ "Cabal test suite - testing cabal version "
++ display cabalVersion
putStrLn $ "Cabal build directory: " ++ dist_dir
putStrLn $ "Test directory: " ++ test_dir
putStrLn $ "Cabal source directory: " ++ cabal_dir
-- TODO: it might be useful to factor this out so that ./Setup
-- configure dumps this file, so we can read it without in a version
-- stable way.
putStrLn $ "Environment:"
putStrLn $ "CABAL_PACKAGETESTS_GHC=" ++ show ghc_path ++ " \\"
putStrLn $ "CABAL_PACKAGETESTS_GHC_VERSION="
++ show (display ghc_version) ++ " \\"
putStrLn $ "CABAL_PACKAGETESTS_GHC_PKG=" ++ show ghc_pkg_path ++ " \\"
putStrLn $ "CABAL_PACKAGETESTS_WITH_GHC=" ++ show with_ghc_path ++ " \\"
putStrLn $ "CABAL_PACKAGETESTS_HADDOCK=" ++ show haddock_path ++ " \\"
-- For brevity, do pre-canonicalization
putStrLn $ "CABAL_PACKAGETESTS_DB_STACK=" ++
show (intercalate [searchPathSeparator]
(showPackageDbList (uninterpretPackageDBFlags
packageDBStack0)))
putStrLn $ "CABAL_PACKAGETESTS_GHC=" ++ show (ghcPath suite) ++ " \\"
putStrLn $ "CABAL_PACKAGETESTS_GHC_PKG=" ++ show (ghcPkgPath suite) ++ " \\"
putStrLn $ "CABAL_PACKAGETESTS_WITH_GHC=" ++ show (withGhcPath suite) ++ " \\"
putStrLn $ "CABAL_PACKAGETESTS_WITH_GHC_PKG=" ++ show (withGhcPkgPath suite) ++ " \\"
-- For brevity, we use the pre-canonicalized values
let showDBStack = show
. intercalate [searchPathSeparator]
. showPackageDbList
. uninterpretPackageDBFlags
putStrLn $ "CABAL_PACKAGETESTS_DB_STACK=" ++ showDBStack packageDBStack0
putStrLn $ "CABAL_PACKAGETESTS_WITH_DB_STACK=" ++ showDBStack withGhcDBStack0
-- Create a shared Setup executable to speed up Simple tests
putStrLn $ "Building shared ./Setup executable"
......@@ -260,22 +300,15 @@ canonicalizePackageDB x = return x
-- take a different approach (either setting "build-type: Custom"
-- so we bootstrap with the most recent Cabal, or by writing the
-- information we need in another format.)
getPersistBuildConfig_ :: FilePath -> IO LocalBuildInfo
getPersistBuildConfig_ :: FilePath -> IO (Maybe LocalBuildInfo)
getPersistBuildConfig_ filename = do
eLBI <- try $ getConfigStateFile filename
case eLBI of
Left (ConfigStateFileBadVersion _ _ (Right lbi)) -> return lbi
-- These errors are lazy! We might not need these parameters.
Left (ConfigStateFileBadVersion _ _ (Left err))
-> return . error $
"We couldn't understand the build configuration. Try " ++
"editing Cabal.cabal to have 'build-type: Custom' " ++
"and then rebuilding, or manually specifying CABAL_PACKAGETESTS_* " ++
"environment variables (see README.md for more details)." ++
"\n\nOriginal error: " ++
show err
Left err -> return (throw err)
Right lbi -> return lbi
-- If the version doesn't match but we still got a successful
-- parse, don't complain and just use it!
Left (ConfigStateFileBadVersion _ _ (Right lbi)) -> return (Just lbi)
Left _ -> return Nothing
Right lbi -> return (Just lbi)
options :: [Ingredient]
options = includingOptions
......
......@@ -3,7 +3,7 @@ import C
#ifdef VERSION_filepath
#error "Should not see macro from library"
#endif
#ifdef VERSION_deepseq
#ifdef VERSION_directory
#error "Should not see macro from executable macros-a"
#endif
main = do
......
......@@ -14,7 +14,7 @@ library macros
executable macros-a
main-is: A.hs
build-depends: base, deepseq, macros
build-depends: base, directory, macros
default-language: Haskell2010
executable macros-b
......
{-# LANGUAGE CPP #-}
module C where
#ifdef VERSION_deepseq
#ifdef VERSION_directory
#error "Should not see macro from executable macros-a"
#endif
#ifdef VERSION_containers
......
......@@ -11,6 +11,11 @@ module PackageTests.PackageTester
, runTestM
-- * Paths
, ghcPath
, withGhcPath
, ghcPkgPath
, withGhcPkgPath
, packageDir
, distDir
, relativeDistDir
......@@ -64,6 +69,7 @@ module PackageTests.PackageTester
, testUnless
, unlessWindows
, hasSharedLibraries
, hasCabalForGhc
, getPersistBuildConfig
......@@ -79,6 +85,9 @@ import PackageTests.Options
import Distribution.Compat.CreatePipe (createPipe)
import Distribution.Simple.Compiler (PackageDBStack, PackageDB(..))
import Distribution.Simple.Program.Run (getEffectiveEnvironment)
import Distribution.Simple.Program.Types
import Distribution.Simple.Program.Db
import Distribution.Simple.Program
import Distribution.System (OS(Windows), buildOS)
import Distribution.Simple.Utils
( printRawCommandAndArgsAndEnv, withFileContents )
......@@ -154,30 +163,94 @@ onlyIfExists m = liftIO $
-- | Global configuration for the entire test suite.
data SuiteConfig = SuiteConfig
-- | Path to GHC that was used to compile Cabal library under test.
{ ghcPath :: FilePath
-- | Version of GHC that compiled Cabal.
, ghcVersion :: Version
-- | Path to ghc-pkg corresponding to 'ghcPath'.
, ghcPkgPath :: FilePath
-- | Path to GHC that we should use to "./Setup --with-ghc"
, withGhcPath :: FilePath
-- | Version of GHC at 'withGhcPath'.
, withGhcVersion :: Version
-- | The programs used to build the Cabal under test.
-- Invariant: ghc and ghc-pkg are configured.
{ bootProgramsConfig :: ProgramDb
-- | The programs that are requested using @--with-compiler@
-- and @--with-hc-pkg@ to Cabal the under-test.
-- Invariant: ghc and ghc-pkg are configured.
, withProgramsConfig :: ProgramDb
-- | The build directory that was used to build Cabal (used
-- to compile Setup scripts.)
, cabalDistPref :: FilePath
-- | Configuration options you can use to make the Cabal
-- being tested visible (e.g. if you're using the test runner).
-- | The package database stack which makes the *built*
-- Cabal well-formed. In general, this is going to be
-- the package DB stack from the LBI you used to build
-- Cabal, PLUS the inplace database (since you also want Cabal).
-- TODO: I forgot what this comment means:
-- We don't add these by default because then you have to
-- link against Cabal which makes the build go longer.
, packageDBStack :: PackageDBStack
-- | The package database stack for 'withGhcPath'. This
-- is ignored if @'withGhcPath' suite == 'ghcPath' suite@.
-- We don't assume this includes the inplace database (since
-- Cabal would have been built with the wrong version of GHC,
-- so the databases aren't compatible anyway.)
, withGhcDBStack :: PackageDBStack
-- | How verbose should we be
, suiteVerbosity :: Verbosity
-- | The absolute current working directory
, absoluteCWD :: FilePath
}
getProgram :: ProgramDb -> Program -> ConfiguredProgram
getProgram conf program = prog
where Just prog = lookupProgram program conf -- invariant!
getBootProgram :: SuiteConfig -> Program -> ConfiguredProgram
getBootProgram suite = getProgram (bootProgramsConfig suite)
getWithProgram :: SuiteConfig -> Program -> ConfiguredProgram
getWithProgram suite = getProgram (withProgramsConfig suite)
ghcProg :: SuiteConfig -> ConfiguredProgram
ghcProg suite = getBootProgram suite ghcProgram
withGhcProg :: SuiteConfig -> ConfiguredProgram
withGhcProg suite = getWithProgram suite ghcProgram
withGhcPkgProg :: SuiteConfig -> ConfiguredProgram
withGhcPkgProg suite = getWithProgram suite ghcPkgProgram
programVersion' :: ConfiguredProgram -> Version
programVersion' prog = version
where Just version = programVersion prog -- invariant!
ghcPath :: SuiteConfig -> FilePath
ghcPath = programPath . ghcProg
-- Basically you should never use these two...
ghcPkgProg :: SuiteConfig -> ConfiguredProgram
ghcPkgProg suite = getBootProgram suite ghcPkgProgram
ghcPkgPath :: SuiteConfig -> FilePath
ghcPkgPath = programPath . ghcPkgProg
ghcVersion :: SuiteConfig -> Version
ghcVersion = programVersion' . ghcProg
withGhcPath :: SuiteConfig -> FilePath
withGhcPath = programPath . withGhcProg
withGhcVersion :: SuiteConfig -> Version
withGhcVersion = programVersion' . withGhcProg
-- Ditto...
withGhcPkgPath :: SuiteConfig -> FilePath
withGhcPkgPath = programPath . withGhcPkgProg
-- Selects the correct database stack to pass to the Cabal under
-- test as the "database stack" to use for testing. This may be
-- something different if the GHC we want Cabal to use is different
-- from the GHC Cabal was built with.
testDBStack :: SuiteConfig -> PackageDBStack
testDBStack suite
| withGhcPath suite == ghcPath suite
= packageDBStack suite
| otherwise
= withGhcDBStack suite
data TestConfig = TestConfig
-- | Test name, MUST be the directory the test packages live in
-- relative to tests/PackageTests
......@@ -313,9 +386,7 @@ cabal' cmd extraArgs0 = do
, "--prefix=" ++ prefix_dir
] -- Only add the LBI package stack if the GHC version
-- matches.
++ (if withGhcPath suite == ghcPath suite
then packageDBParams (packageDBStack suite)
else [])
++ packageDBParams (testDBStack suite)
++ extraArgs0
_ -> extraArgs0
-- This is a horrible hack to make hpc work correctly
......@@ -378,6 +449,7 @@ rawCompileSetup :: Verbosity -> SuiteConfig -> [(String, Maybe String)] -> FileP
rawCompileSetup verbosity suite e path = do
-- NB: Use 'ghcPath', not 'withGhcPath', since we need to be able to
-- link against the Cabal library which was built with 'ghcPath'.
-- Ditto with packageDBStack.
r <- rawRun verbosity (Just path) (ghcPath suite) e $
[ "--make"] ++
ghcPackageDBParams (ghcVersion suite) (packageDBStack suite) ++
......@@ -429,13 +501,13 @@ ghcPkg cmd args = void (ghcPkg' cmd args)
ghcPkg' :: String -> [String] -> TestM Result
ghcPkg' cmd args = do
db_path <- sharedDBPath
(config, test) <- ask
unless (testPackageDb test) $
error "Must initialize package database using withPackageDb"
let db_stack = packageDBStack config ++ [SpecificPackageDB db_path]
extraArgs = ghcPkgPackageDBParams (ghcVersion config) db_stack
run Nothing (ghcPkgPath config) (cmd : extraArgs ++ args)
-- NB: testDBStack already has the local database
let db_stack = testDBStack config
extraArgs = ghcPkgPackageDBParams (withGhcVersion config) db_stack
run Nothing (withGhcPkgPath config) (cmd : extraArgs ++ args)
ghcPkgPackageDBParams :: Version -> PackageDBStack -> [String]
ghcPkgPackageDBParams version dbs = concatMap convert dbs where
......@@ -589,7 +661,7 @@ shouldFail = withReaderT (\(suite, test) -> (suite, test { testShouldFail = not
whenGhcVersion :: (Version -> Bool) -> TestM () -> TestM ()
whenGhcVersion p m = do
(suite, _) <- ask
when (p (ghcVersion suite)) m
when (p (withGhcVersion suite)) m
withPackage :: FilePath -> TestM a -> TestM a
withPackage f = withReaderT (\(suite, test) -> (suite, test { testCurrentPackage = f }))
......@@ -612,7 +684,10 @@ withPackageDb m = do
else withReaderT (\(suite, test) ->
(suite { packageDBStack
= packageDBStack suite
++ [SpecificPackageDB db_path] },
++ [SpecificPackageDB db_path]
, withGhcDBStack
= withGhcDBStack suite
++ [SpecificPackageDB db_path]},
test { testPackageDb = True }))
$ do ghcPkg "init" [db_path]
m
......@@ -690,6 +765,10 @@ hasSharedLibraries :: SuiteConfig -> Bool
hasSharedLibraries config =
buildOS /= Windows || withGhcVersion config < Version [7,8] []
hasCabalForGhc :: SuiteConfig -> Bool
hasCabalForGhc config =
withGhcPath config == ghcPath config
------------------------------------------------------------------------
-- Verbosity
......
......@@ -36,14 +36,20 @@ tests config = do
---------------------------------------------------------------------
-- * Test suite tests
groupTests "TestSuiteTests/ExeV10" $
-- TODO: This shouldn't be necessary, but there seems to be some
-- bug in the way the test is written. Not going to lose sleep
-- over this... but would be nice to fix.
testWhen (hasCabalForGhc config)
. groupTests "TestSuiteTests/ExeV10" $
(PackageTests.TestSuiteTests.ExeV10.Check.tests config)
-- Test if detailed-0.9 builds correctly
tcs "TestSuiteTests/LibV09" "Build" $ cabal_build ["--enable-tests"]
testWhen (hasCabalForGhc config)