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 cpp-options: -DGHC_STABLE
default-extensions: default-extensions:
BangPatterns BangPatterns
DeriveFunctor
DeriveGeneric DeriveGeneric
GeneralizedNewtypeDeriving GeneralizedNewtypeDeriving
LambdaCase LambdaCase
NamedFieldPuns NamedFieldPuns
OverloadedStrings
RecordWildCards RecordWildCards
ScopedTypeVariables ScopedTypeVariables
StandaloneDeriving StandaloneDeriving
@ -74,6 +76,7 @@ library
exposed-modules: exposed-modules:
Development.IDE.Core.FileStore Development.IDE.Core.FileStore
Development.IDE.Core.OfInterest Development.IDE.Core.OfInterest
Development.IDE.Core.PositionMapping
Development.IDE.Core.Rules Development.IDE.Core.Rules
Development.IDE.Core.RuleTypes Development.IDE.Core.RuleTypes
Development.IDE.Core.Service Development.IDE.Core.Service
@ -131,3 +134,26 @@ executable hie-core
RecordWildCards RecordWildCards
TupleSections TupleSections
ViewPatterns 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: subdirs:
- . - .
- haskell-lsp-types - haskell-lsp-types
- git: https://github.com/digital-asset/lsp-test.git
commit: 50c43452e19e494d71ccba1f7922d0b3b3fc69c3
- git: https://github.com/mpickering/hie-bios.git - git: https://github.com/mpickering/hie-bios.git
commit: 8427e424a83c2f3d60bdd26c02478c00d2189a73 commit: 8427e424a83c2f3d60bdd26c02478c00d2189a73
nix: 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( da_haskell_test(
name = "hie-core-tests", name = "hie-core-tests",
srcs = glob(["exe/**/*.hs"]), srcs = glob(["exe/**/*.hs"]),
@ -43,8 +57,8 @@ da_haskell_test(
], ],
src_strip_prefix = "exe", src_strip_prefix = "exe",
deps = [ deps = [
":hie-core-test-runfiles",
":hie-core-testing",
"//compiler/hie-core", "//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. -- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0 -- SPDX-License-Identifier: Apache-2.0
{-# LANGUAGE DuplicateRecordFields #-}
module Main (main) where module Main (main) where
import Control.Monad (void) import Control.Monad (void)
import qualified Data.Text as T import qualified Data.Text as T
import Development.IDE.Test import Development.IDE.Test
import Development.IDE.Test.Runfiles
import Language.Haskell.LSP.Test import Language.Haskell.LSP.Test
import Language.Haskell.LSP.Types import Language.Haskell.LSP.Types
import System.Environment.Blank (setEnv) import System.Environment.Blank (setEnv)
import System.FilePath
import System.IO.Extra import System.IO.Extra
import Test.Tasty import Test.Tasty
import Test.Tasty.HUnit import Test.Tasty.HUnit
import DA.Bazel.Runfiles
main :: IO () main :: IO ()
main = defaultMain $ testGroup "HIE" main = defaultMain $ testGroup "HIE"
@ -60,8 +59,7 @@ testSession name = testCase name . run
run :: Session a -> IO a run :: Session a -> IO a
run s = withTempDir $ \dir -> do run s = withTempDir $ \dir -> do
let hieCoreExePath = mainWorkspace </> exe "compiler/hie-core/hie-core-exe" hieCoreExe <- locateHieCoreExecutable
hieCoreExe <- locateRunfiles hieCoreExePath
let cmd = unwords [hieCoreExe, "--lsp", "--cwd", dir] let cmd = unwords [hieCoreExe, "--lsp", "--cwd", dir]
-- HIE calls getXgdDirectory which assumes that HOME is set. -- HIE calls getXgdDirectory which assumes that HOME is set.
-- Only sets HOME if it wasn't already set. -- Only sets HOME if it wasn't already set.