Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add more verbose debugging output, make test script work with GHC 6.8

  • Loading branch information...
commit 7c995fe6b1f16186ddcf5fb98bcadc70049263b8 1 parent 2d401a8
Josh Hoyt authored
View
15 bin/runtests
@@ -13,14 +13,17 @@ function init-pkg-db {
VER_STR="$(ghc-pkg --version)"
case "$VER_STR" in
"GHC package manager version 6.8."*)
+ GHCVER=6.8
PKGDB=${SANDBOX}/packages-6.8.conf
[ -f "${PKGDB}" ] || echo -n "[]" > "${PKGDB}"
;;
"GHC package manager version 6.10."*)
+ GHCVER=6.10
PKGDB=${SANDBOX}/packages-6.10.conf
[ -f "${PKGDB}" ] || echo -n "[]" > "${PKGDB}"
;;
"GHC package manager version 6.12."*)
+ GHCVER=6.12
PKGDB=${SANDBOX}/packages.conf.d
[ -d "${PKGDB}" ] || ghc-pkg init "${PKGDB}"
;;
@@ -53,8 +56,16 @@ rewriteCabalConfig () {
mkdir -p $SANDBOX
init-pkg-db
rewriteCabalConfig admin/cabal-config.in "${SANDBOX}/cabal.config"
-cabal --config-file="${SANDBOX}/cabal.config" install
-
+case ${GHCVER} in
+ 6.8)
+ CABALARGS="--with-ghc-pkg=$(which ghc-pkg-6.8-compat) \
+ --ghc-pkg-options=--with-ghc-pkg=$(which ghc-pkg)"
+ ;;
+ *)
+ CABALARGS=
+ ;;
+esac
+cabal ${CABALARGS} --config-file="${SANDBOX}/cabal.config" install
cat <<EOF
==================================================
Now using the compiled binary:
View
18 src/Distribution/Dev/InitPkgDb.hs
@@ -11,7 +11,7 @@ import Distribution.Simple.Program ( ghcPkgProgram, requireProgram
, programLocation, locationPath
)
import Distribution.Version ( Version(..) )
-
+import Distribution.Verbosity ( Verbosity )
-- This makes MIN_VERSION_Cabal testing use the first option in the
-- absence of the macro (compilation without Cabal)
@@ -46,19 +46,19 @@ import Distribution.Dev.Sandbox ( Sandbox, pkgConf, PackageDbType(..)
-- different GHC versions, but the cabal-install config file just sets
-- one location. We'd have to have the GHC version before writing the
-- cabal config file.
-initPkgDb :: Sandbox UnknownVersion -> IO (Sandbox KnownVersion)
-initPkgDb s = do
+initPkgDb :: Verbosity -> Sandbox UnknownVersion -> IO (Sandbox KnownVersion)
+initPkgDb v s = do
#if MIN_VERSION_Cabal(1,8,0)
- let require v p = requireProgram v p emptyProgramDb
+ let require p = requireProgram v p emptyProgramDb
run = runProgram
#elif MIN_VERSION_Cabal(1,2,0)
- let require v p = requireProgram v p AnyVersion emptyProgramConfiguration
+ let require p = requireProgram v p AnyVersion emptyProgramConfiguration
run = rawSystemProgram
#else
#error Cabal version not supported
#endif
- ghcPkg <- fst `fmap` require V.normal ghcPkgProgram
+ ghcPkg <- fst `fmap` require ghcPkgProgram
let typ = ghcPackageDbType ghcPkg
s' = setVersion s typ
pth = pkgConf s'
@@ -66,7 +66,7 @@ initPkgDb s = do
case typ of
GHC_6_12_Db -> do
e <- doesDirectoryExist pth
- unless e $ run V.normal ghcPkg ["init", pth]
+ unless e $ run v ghcPkg ["init", pth]
_ -> do
e <- doesFileExist pth
unless e $ writeFile pth "[]"
@@ -76,6 +76,8 @@ ghcPackageDbType :: ConfiguredProgram -> PackageDbType
ghcPackageDbType p =
case programVersion p of
Nothing -> error "Unknown ghc version!"
- Just v | v < Version [6, 10] [] -> (GHC_6_8_Db $ locationPath $ programLocation p)
+ Just v | v < Version [6, 10] [] -> GHC_6_8_Db $
+ locationPath $
+ programLocation p
| v < Version [6, 12] [] -> GHC_6_10_Db
| otherwise -> GHC_6_12_Db
View
14 src/Distribution/Dev/InvokeCabal.hs
@@ -16,6 +16,7 @@ import Distribution.Simple.Program ( findProgramOnPath )
#else
#error Cabal version unsupported
#endif
+import Distribution.Simple.Utils ( notice )
import System.Console.GetOpt ( OptDescr )
import System.Directory ( canonicalizePath )
import System.Exit ( ExitCode(..) )
@@ -53,17 +54,19 @@ actions act = CommandActions
invokeCabal :: [GlobalFlag] -> [String] -> IO CommandResult
invokeCabal flgs args = do
- either (return . CommandError) (invokeCabalCfg . (++ args)) =<< setup flgs
+ let v = getVerbosity flgs
+ either (return . CommandError) (invokeCabalCfg v . (++ args)) =<< setup flgs
setup :: [GlobalFlag] -> IO (Either String [String])
setup flgs = do
- s <- initPkgDb =<< resolveSandbox flgs
+ let v = getVerbosity flgs
+ s <- initPkgDb v =<< resolveSandbox flgs
cfgIn <- getCabalConfig flgs
let cfgOut = cabalConf s
cfgRes <- rewriteCabalConfig cfgIn cfgOut s
let qualifyError err =
"Error processing cabal config file " ++ cfgIn ++ ": " ++ err
- args <- extraArgs (getVerbosity flgs) cfgOut (getVersion s)
+ args <- extraArgs v cfgOut (getVersion s)
return $
left qualifyError $
right (const $ args) $
@@ -89,8 +92,9 @@ extraArgs v cfg pdb =
]
_ -> return []
-invokeCabalCfg :: [String] -> IO CommandResult
-invokeCabalCfg args = do
+invokeCabalCfg :: Verbosity -> [String] -> IO CommandResult
+invokeCabalCfg v args = do
+ notice v $ unwords $ "Invoking: cabal":args
res <- rawSystem "cabal" args
return $ case res of
ExitSuccess -> CommandOk
View
2  src/GhcPkgCompat.hs
@@ -25,7 +25,6 @@ import Distribution.Simple.Utils ( rawSystemExit )
import Control.Monad ( msum )
import Data.Maybe ( fromMaybe, isJust )
import System.Environment ( getArgs )
-import System.IO ( withFile, IOMode(AppendMode), hPutStrLn )
dropCommonPrefix :: Eq a => [a] -> [a] -> ([a], [a])
dropCommonPrefix (a:as) (b:bs) | a == b = dropCommonPrefix as bs
@@ -65,5 +64,4 @@ main = do
let ghcPkg = ghcPkgExe args
ghcPkgArgs = fixPackageDbSpec $ filter (not . shouldDrop) args
v = silent
- withFile "xxx" AppendMode $ \h -> hPutStrLn h $ show $ ghcPkg:ghcPkgArgs
rawSystemExit v ghcPkg ghcPkgArgs
Please sign in to comment.
Something went wrong with that request. Please try again.