diff --git a/.gitignore b/.gitignore index 05fd776..c3e127b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ elisp/*.elc *~ /.cabal-sandbox/ /.stack-work/ +/test/data/**/stack.yaml add-source-timestamps package.cache cabal.sandbox.config diff --git a/test/Main.hs b/test/Main.hs index 3558f56..234b4fb 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -4,7 +4,6 @@ import Dir import Control.Exception as E import Control.Monad (void) -import Data.List import Language.Haskell.GhcMod (debugInfo) import System.Process import System.Environment @@ -29,34 +28,24 @@ main = do , "test/data/duplicate-pkgver/.cabal-sandbox/i386-osx-ghc-7.6.3-packages.conf.d"] genGhcPkgCache dir = system $ "ghc-pkg recache --force -f" ++ dir - genSandboxCfg `mapM_` sandboxes - genGhcPkgCache `mapM_` pkgDirs - - let caches = [ "setup-config" - , "setup-config.ghc-mod.cabal-helper" - , "setup-config.ghc-mod.cabal-components" - , "setup-config.ghc-mod.resolved-components" - , "setup-config.ghc-mod.package-options" - , "setup-config.ghc-mod.package-db-stack" - , "ghc-mod.cache" - ] - findExp = unwords $ intersperse "-o " $ concat [ - stackWorkFindExp, - cachesFindExp - ] - cachesFindExp = map ("-name "++) caches - stackWorkFindExp = ["-name .stack-work -type d"] - - cleanCmd = "find test \\( "++ findExp ++" \\) -exec rm -r {} \\;" - + let cleanCmd = "git clean -dXf test/data/" putStrLn $ "$ " ++ cleanCmd void $ system cleanCmd void $ system "cabal --version" void $ system "ghc --version" + genSandboxCfg `mapM_` sandboxes + genGhcPkgCache `mapM_` pkgDirs + let stackDir = "test/data/stack-project" void $ withDirectory_ stackDir $ do --- void $ system "stack init --force" + let ghcver = let gvn = show (__GLASGOW_HASKELL__ :: Int) + (major, minor') = splitAt (length gvn - 2) gvn + minor = case dropWhile (=='0') minor' of + "" -> "0" + x -> x + in major ++ "." ++ minor + void $ system $ "sed '$ a resolver: ghc-" ++ ghcver ++ "' stack.yaml.in > stack.yaml" void $ system "stack setup" void $ system "stack build" diff --git a/test/data/stack-project/stack.yaml b/test/data/stack-project/stack.yaml.in similarity index 68% rename from test/data/stack-project/stack.yaml rename to test/data/stack-project/stack.yaml.in index 6252712..170293a 100644 --- a/test/data/stack-project/stack.yaml +++ b/test/data/stack-project/stack.yaml.in @@ -2,4 +2,3 @@ flags: {} packages: - '.' extra-deps: [] -resolver: lts-2.17