From 6496b641c9266a97afe7169f1c90ef38f93054ff Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Wed, 3 Aug 2016 14:14:31 +0300 Subject: [PATCH] Fix `stack test` the easy way --- Language/Haskell/GhcMod/Utils.hs | 8 ++++++-- test/Main.hs | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Language/Haskell/GhcMod/Utils.hs b/Language/Haskell/GhcMod/Utils.hs index 15782b0..19a0eba 100644 --- a/Language/Haskell/GhcMod/Utils.hs +++ b/Language/Haskell/GhcMod/Utils.hs @@ -40,7 +40,7 @@ import System.IO.Temp (createTempDirectory) import System.Process (readProcess) import Text.Printf -import Paths_ghc_mod (getLibexecDir) +import Paths_ghc_mod (getLibexecDir, getBinDir) import Utils import Prelude @@ -84,7 +84,11 @@ ghcModExecutable = do dir <- takeDirectory <$> getExecutablePath' return $ (if dir == "." then "" else dir) "ghc-mod" #else -ghcModExecutable = fmap ( "dist/build/ghc-mod/ghc-mod") getCurrentDirectory +ghcModExecutable = do + gpp <- lookupEnv "STACK_EXE" + case gpp of + Just _ -> fmap ( "ghc-mod") getBinDir + _ -> fmap ( "dist/build/ghc-mod/ghc-mod") getCurrentDirectory #endif getExecutablePath' :: IO FilePath diff --git a/test/Main.hs b/test/Main.hs index 2e9f558..cddfa2e 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -7,11 +7,13 @@ import Control.Monad (void) import Data.List import Language.Haskell.GhcMod (debugInfo) import System.Process +import System.Environment import Test.Hspec import TestUtils main :: IO () main = do + unsetEnv "GHC_PACKAGE_PATH" let sandboxes = [ "test/data/cabal-project" , "test/data/check-packageid" , "test/data/duplicate-pkgver/"