Fix tests more

This commit is contained in:
Daniel Gröber 2015-09-14 07:11:45 +02:00
parent ba14e1790c
commit 55f278853a
2 changed files with 22 additions and 4 deletions

View File

@ -43,7 +43,7 @@ findCradle' dir = run $
findSpecCradle :: (IOish m, GmOut m) => FilePath -> m Cradle
findSpecCradle dir = do
let cfs = [stackCradle, cabalCradle, sandboxCradle]
let cfs = [stackCradleSpec, cabalCradle, sandboxCradle]
cs <- catMaybes <$> mapM (runMaybeT . ($ dir)) cfs
gcs <- filterM isNotGmCradle cs
fillTempDir =<< case gcs of
@ -99,6 +99,19 @@ stackCradle wdir = do
, cradleDistDir = seDistDir senv
}
stackCradleSpec :: (IOish m, GmOut m) => FilePath -> MaybeT m Cradle
stackCradleSpec wdir = do
crdl <- stackCradle wdir
case crdl of
Cradle { cradleProject = StackProject StackEnv { seDistDir } } -> do
b <- isGmDistDir seDistDir
when b mzero
return crdl
_ -> error "stackCradleSpec"
where
isGmDistDir dir =
liftIO $ not <$> doesFileExist (dir </> ".." </> "ghc-mod.cabal")
sandboxCradle :: IOish m => FilePath -> MaybeT m Cradle
sandboxCradle wdir = do
sbDir <- MaybeT $ liftIO $ findCabalSandboxDir wdir

View File

@ -69,9 +69,14 @@ withGhcModEnv' withCradle dir opts f =
c <- gmoChan <$> gmoAsk
gbracket_ (liftIO $ forkIO $ stdoutGateway c) (liftIO . killThread) a
withCradleRootDir (cradleRootDir -> projdir) =
gbracket_ (liftIO $ setCurrentDirectory projdir >> getCurrentDirectory)
(liftIO . setCurrentDirectory)
withCradleRootDir (cradleRootDir -> projdir) a =
gbracket_ (liftIO $ swapCurrentDirectory projdir)
(liftIO . setCurrentDirectory) a
swapCurrentDirectory ndir = do
odir <- canonicalizePath =<< getCurrentDirectory
setCurrentDirectory ndir
return odir
gbracket_ ma mb mc = gbracket ma mb (const mc)