Merge pull request #154 from eagletmt/sandbox-dist

Fix `cabal install --enable-tests` in a sandbox environment
This commit is contained in:
Kazu Yamamoto 2013-10-06 22:43:27 -07:00
commit 79a18ff379
2 changed files with 15 additions and 1 deletions

View File

@ -131,6 +131,8 @@ Test-Suite spec
, time
, transformers
, hspec >= 1.7.1
if impl(ghc < 7.6.0)
Build-Depends: executable-path
Source-Repository head
Type: git

View File

@ -1,9 +1,17 @@
{-# LANGUAGE CPP #-}
module InfoSpec where
import Control.Applicative ((<$>))
import Data.List (isPrefixOf)
import Language.Haskell.GhcMod
import Language.Haskell.GhcMod.Cradle
#ifdef VERSION_executable_path
import System.Environment.Executable (getExecutablePath)
#else
import System.Environment (getExecutablePath)
#endif
import System.Exit
import System.FilePath
import System.Process
import Test.Hspec
@ -50,5 +58,9 @@ spec = do
res `shouldSatisfy` ("bar :: [Char]" `isPrefixOf`)
it "doesn't fail on unicode output" $ do
code <- rawSystem "dist/build/ghc-mod/ghc-mod" ["info", "test/data/Unicode.hs", "Unicode", "unicode"]
dir <- getDistDir
code <- rawSystem (dir </> "build/ghc-mod/ghc-mod") ["info", "test/data/Unicode.hs", "Unicode", "unicode"]
code `shouldSatisfy` (== ExitSuccess)
getDistDir :: IO FilePath
getDistDir = takeDirectory . takeDirectory . takeDirectory <$> getExecutablePath