2014-05-10 00:04:09 +00:00
|
|
|
{-# LANGUAGE CPP, ScopedTypeVariables #-}
|
2014-04-15 03:13:10 +00:00
|
|
|
import Spec
|
|
|
|
import Dir
|
|
|
|
|
2014-05-09 18:37:55 +00:00
|
|
|
import Control.Exception as E
|
2014-08-20 03:14:27 +00:00
|
|
|
import Control.Monad (void)
|
2015-03-04 20:48:21 +00:00
|
|
|
import Data.List
|
2014-08-20 03:14:27 +00:00
|
|
|
import Language.Haskell.GhcMod (debugInfo)
|
|
|
|
import System.Process
|
2016-08-03 11:14:31 +00:00
|
|
|
import System.Environment
|
2014-08-20 03:14:27 +00:00
|
|
|
import Test.Hspec
|
2014-07-11 01:10:37 +00:00
|
|
|
import TestUtils
|
2014-05-09 18:37:55 +00:00
|
|
|
|
2014-08-20 03:14:27 +00:00
|
|
|
main :: IO ()
|
2014-04-15 03:13:10 +00:00
|
|
|
main = do
|
2016-08-03 11:25:05 +00:00
|
|
|
#if __GLASGOW_HASKELL__ >= 708
|
2016-08-03 11:14:31 +00:00
|
|
|
unsetEnv "GHC_PACKAGE_PATH"
|
2016-08-03 11:25:05 +00:00
|
|
|
#endif
|
2015-03-04 20:48:21 +00:00
|
|
|
let sandboxes = [ "test/data/cabal-project"
|
|
|
|
, "test/data/check-packageid"
|
2014-08-12 16:12:12 +00:00
|
|
|
, "test/data/duplicate-pkgver/"
|
|
|
|
, "test/data/broken-cabal/"
|
|
|
|
]
|
2014-08-20 03:14:27 +00:00
|
|
|
genSandboxCfg dir = withDirectory dir $ \cwdir -> do
|
|
|
|
system ("sed 's|@CWD@|" ++ cwdir ++ "|g' cabal.sandbox.config.in > cabal.sandbox.config")
|
2014-04-23 02:08:54 +00:00
|
|
|
pkgDirs =
|
2015-03-04 20:48:21 +00:00
|
|
|
[ "test/data/cabal-project/.cabal-sandbox/i386-osx-ghc-7.6.3-packages.conf.d"
|
2014-04-28 15:49:15 +00:00
|
|
|
, "test/data/check-packageid/.cabal-sandbox/i386-osx-ghc-7.6.3-packages.conf.d"
|
|
|
|
, "test/data/duplicate-pkgver/.cabal-sandbox/i386-osx-ghc-7.6.3-packages.conf.d"]
|
2014-04-23 02:08:54 +00:00
|
|
|
genGhcPkgCache dir = system $ "ghc-pkg recache --force -f" ++ dir
|
2015-03-04 20:48:21 +00:00
|
|
|
|
2014-04-23 02:08:54 +00:00
|
|
|
genSandboxCfg `mapM_` sandboxes
|
|
|
|
genGhcPkgCache `mapM_` pkgDirs
|
2015-03-04 20:48:21 +00:00
|
|
|
|
|
|
|
let caches = [ "setup-config"
|
|
|
|
, "setup-config.ghc-mod.cabal-helper"
|
2015-08-07 04:47:34 +00:00
|
|
|
, "setup-config.ghc-mod.cabal-components"
|
2015-03-28 01:33:42 +00:00
|
|
|
, "setup-config.ghc-mod.resolved-components"
|
2015-08-07 04:47:34 +00:00
|
|
|
, "setup-config.ghc-mod.package-options"
|
|
|
|
, "setup-config.ghc-mod.package-db-stack"
|
2015-03-04 20:48:21 +00:00
|
|
|
, "ghc-mod.cache"
|
|
|
|
]
|
2015-08-19 04:48:27 +00:00
|
|
|
findExp = unwords $ intersperse "-o " $ concat [
|
|
|
|
stackWorkFindExp,
|
|
|
|
cachesFindExp
|
|
|
|
]
|
|
|
|
cachesFindExp = map ("-name "++) caches
|
|
|
|
stackWorkFindExp = ["-name .stack-work -type d"]
|
2015-03-04 20:48:21 +00:00
|
|
|
|
2015-08-19 04:48:27 +00:00
|
|
|
cleanCmd = "find test \\( "++ findExp ++" \\) -exec rm -r {} \\;"
|
2015-03-04 20:48:21 +00:00
|
|
|
|
2015-03-28 01:33:42 +00:00
|
|
|
putStrLn $ "$ " ++ cleanCmd
|
2015-03-04 20:48:21 +00:00
|
|
|
void $ system cleanCmd
|
2014-08-20 03:14:27 +00:00
|
|
|
void $ system "cabal --version"
|
|
|
|
void $ system "ghc --version"
|
2014-05-09 18:37:55 +00:00
|
|
|
|
2015-08-19 04:48:27 +00:00
|
|
|
let stackDir = "test/data/stack-project"
|
|
|
|
void $ withDirectory_ stackDir $ do
|
|
|
|
-- void $ system "stack init --force"
|
|
|
|
void $ system "stack setup"
|
|
|
|
void $ system "stack build"
|
|
|
|
|
2014-07-11 01:10:37 +00:00
|
|
|
(putStrLn =<< runD debugInfo)
|
2014-05-09 18:37:55 +00:00
|
|
|
`E.catch` (\(_ :: E.SomeException) -> return () )
|
|
|
|
|
2014-04-15 03:13:10 +00:00
|
|
|
hspec spec
|