stack/cabal for hie-core-tests (#2287)

* stack/cabal for hie-core-tests

* ./fmt.sh
This commit is contained in:
Andreas Herrmann 2019-07-25 14:50:07 +02:00 committed by Gary Verhaegen
parent 8ab246bcdb
commit ae37b4b21c
6 changed files with 75 additions and 7 deletions

View File

@ -58,10 +58,12 @@ library
cpp-options: -DGHC_STABLE
default-extensions:
BangPatterns
DeriveFunctor
DeriveGeneric
GeneralizedNewtypeDeriving
LambdaCase
NamedFieldPuns
OverloadedStrings
RecordWildCards
ScopedTypeVariables
StandaloneDeriving
@ -74,6 +76,7 @@ library
exposed-modules:
Development.IDE.Core.FileStore
Development.IDE.Core.OfInterest
Development.IDE.Core.PositionMapping
Development.IDE.Core.Rules
Development.IDE.Core.RuleTypes
Development.IDE.Core.Service
@ -131,3 +134,26 @@ executable hie-core
RecordWildCards
TupleSections
ViewPatterns
test-suite hie-core-tests
type: exitcode-stdio-1.0
default-language: Haskell2010
build-tool-depends:
hie-core:hie-core
build-depends:
base,
containers,
extra,
filepath,
haskell-lsp-types,
lens,
lsp-test,
parser-combinators,
tasty,
tasty-hunit,
text
hs-source-dirs: test/cabal test/exe test/src
main-is: Main.hs
other-modules:
Development.IDE.Test
Development.IDE.Test.Runfiles

View File

@ -8,6 +8,8 @@ extra-deps:
subdirs:
- .
- haskell-lsp-types
- git: https://github.com/digital-asset/lsp-test.git
commit: 50c43452e19e494d71ccba1f7922d0b3b3fc69c3
- git: https://github.com/mpickering/hie-bios.git
commit: 8427e424a83c2f3d60bdd26c02478c00d2189a73
nix:

View File

@ -27,6 +27,20 @@ da_haskell_library(
],
)
da_haskell_library(
name = "hie-core-test-runfiles",
srcs = glob(["bazel/**/*.hs"]),
hazel_deps = [
"base",
"filepath",
],
src_strip_prefix = "bazel",
visibility = ["//visibility:public"],
deps = [
"//libs-haskell/bazel-runfiles",
],
)
da_haskell_test(
name = "hie-core-tests",
srcs = glob(["exe/**/*.hs"]),
@ -43,8 +57,8 @@ da_haskell_test(
],
src_strip_prefix = "exe",
deps = [
":hie-core-test-runfiles",
":hie-core-testing",
"//compiler/hie-core",
"//compiler/hie-core/test:hie-core-testing",
"//libs-haskell/bazel-runfiles",
],
)

View File

@ -0,0 +1,16 @@
-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Development.IDE.Test.Runfiles
( locateHieCoreExecutable
) where
import System.FilePath ((</>), FilePath)
import DA.Bazel.Runfiles
locateHieCoreExecutable :: IO FilePath
locateHieCoreExecutable = locateRunfiles hieCoreExePath
where
hieCoreExePath = mainWorkspace </> exe "compiler/hie-core/hie-core-exe"

View File

@ -0,0 +1,12 @@
-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Development.IDE.Test.Runfiles
( locateHieCoreExecutable
) where
import System.FilePath (FilePath)
locateHieCoreExecutable :: IO FilePath
locateHieCoreExecutable = pure "hie-core"

View File

@ -1,22 +1,21 @@
-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
{-# LANGUAGE DuplicateRecordFields #-}
module Main (main) where
import Control.Monad (void)
import qualified Data.Text as T
import Development.IDE.Test
import Development.IDE.Test.Runfiles
import Language.Haskell.LSP.Test
import Language.Haskell.LSP.Types
import System.Environment.Blank (setEnv)
import System.FilePath
import System.IO.Extra
import Test.Tasty
import Test.Tasty.HUnit
import DA.Bazel.Runfiles
main :: IO ()
main = defaultMain $ testGroup "HIE"
@ -60,8 +59,7 @@ testSession name = testCase name . run
run :: Session a -> IO a
run s = withTempDir $ \dir -> do
let hieCoreExePath = mainWorkspace </> exe "compiler/hie-core/hie-core-exe"
hieCoreExe <- locateRunfiles hieCoreExePath
hieCoreExe <- locateHieCoreExecutable
let cmd = unwords [hieCoreExe, "--lsp", "--cwd", dir]
-- HIE calls getXgdDirectory which assumes that HOME is set.
-- Only sets HOME if it wasn't already set.