Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit 0bbec7d

Browse files
authored
Merge pull request #1438 from alanz/liquid-tests
Make sure the liquid haskell test files are generated for unit-test
2 parents 7cf1295 + a1b2f8c commit 0bbec7d

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

src/Haskell/Ide/Engine/Plugin/Liquid.hs

+11-2
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,19 @@ runLiquidHaskell fp = do
166166
cp = (shell cmd) { cwd = Just dir }
167167
-- logm $ "runLiquidHaskell:cmd=[" ++ cmd ++ "]"
168168
mpp <- lookupEnv "GHC_PACKAGE_PATH"
169+
mge <- lookupEnv "GHC_ENVIRONMENT"
169170
-- logm $ "runLiquidHaskell:mpp=[" ++ show mpp ++ "]"
171+
-- env <- getEnvironment
172+
-- logm $ "runLiquidHaskell:env=[" ++ show env ++ "]"
170173
(ec,o,e) <- bracket
171-
(unsetEnv "GHC_PACKAGE_PATH")
172-
(\_ -> mapM_ (setEnv "GHC_PACKAGE_PATH") mpp)
174+
(do
175+
unsetEnv "GHC_ENVIRONMENT"
176+
unsetEnv "GHC_PACKAGE_PATH"
177+
)
178+
(\_ -> do
179+
mapM_ (setEnv "GHC_PACKAGE_PATH") mpp
180+
mapM_ (setEnv "GHC_ENVIRONMENT" ) mge
181+
)
173182
(\_ -> readCreateProcessWithExitCode cp "")
174183
-- logm $ "runLiquidHaskell:v=" ++ show (ec,o,e)
175184
return $ Just (ec,[o,e])

test/unit/LiquidSpec.hs

+12-12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
module LiquidSpec where
44

55
import Data.Aeson
6+
import Data.List
67
import qualified Data.ByteString.Lazy as BS
78
import qualified Data.Text as T
89
import qualified Data.Text.IO as T
@@ -11,8 +12,10 @@ import Data.Maybe (isJust)
1112
import Haskell.Ide.Engine.MonadTypes
1213
import Haskell.Ide.Engine.Plugin.Liquid
1314
import System.Directory
15+
import System.Exit
1416
import System.FilePath
1517
import Test.Hspec
18+
import Control.Monad.IO.Class
1619

1720
main :: IO ()
1821
main = hspec spec
@@ -28,18 +31,15 @@ spec = do
2831

2932
-- ---------------------------------
3033

31-
-- AZ: this test has been moved to func-tests, stack > 2.1 sets
32-
-- its own package environment, we can't run it from here.
33-
34-
-- -- This produces some products in /test/testdata/liquid/.liquid/ that is used in subsequent test
35-
-- it "runs the liquid haskell exe" $ do
36-
-- let
37-
-- fp = cwd </> "test/testdata/liquid/Evens.hs"
38-
-- -- fp = "/home/alanz/tmp/haskell-proc-play/Evens.hs"
39-
-- -- uri = filePathToUri fp
40-
-- Just (ef, (msg:_)) <- runLiquidHaskell fp
41-
-- msg `shouldSatisfy` isPrefixOf "RESULT\n[{\"start\":{\"line\":9,\"column\":1},\"stop\":{\"line\":9,\"column\":8},\"message\":\"Error: Liquid Type Mismatch\\n Inferred type\\n VV : {v : Int | v == (7 : int)}\\n \\n not a subtype of Required type\\n VV : {VV : Int | VV mod 2 == 0}\\n"
42-
-- ef `shouldBe` ExitFailure 1
34+
-- This produces some products in /test/testdata/liquid/.liquid/
35+
-- that are used in subsequent test
36+
it "runs the liquid haskell exe" $ do
37+
let
38+
fp = cwd </> "test/testdata/liquid/Evens.hs"
39+
Just (ef, (msg:_)) <- runLiquidHaskell fp
40+
liftIO $ putStrLn $ "msg=" ++ msg
41+
msg `shouldSatisfy` isPrefixOf "RESULT\n[{\"start\":{\"line\""
42+
ef `shouldBe` ExitFailure 1
4343

4444
-- ---------------------------------
4545
it "gets annot file paths" $ do

0 commit comments

Comments
 (0)