on master help sign in
stack/cabal for hie-core-tests (#2287)

* stack/cabal for hie-core-tests * ./fmt.sh

commitae37b4b21c56d296c7c77cd7078be322c2e5b241 authorAndreas Herrmann <42969706+aherrmann-da@users.noreply.github.com> dateThu 25 Jul 2019, 14:50 (7 years ago) parent8ab246b
6 files changed+75−7
hie-core.cabal+26 stack.yaml+2 test/BUILD.bazel+16−2 test/bazel/Development/IDE/Test/Runfiles.hs+16 test/cabal/Development/IDE/Test/Runfiles.hs+12 test/exe/Main.hs+3−5
hie-core.cabal+26
@@ -58,10 +58,12 @@ library
5858 cpp-options: -DGHC_STABLE
5959 default-extensions:
6060 BangPatterns
61+ DeriveFunctor
6162 DeriveGeneric
6263 GeneralizedNewtypeDeriving
6364 LambdaCase
6465 NamedFieldPuns
66+ OverloadedStrings
6567 RecordWildCards
6668 ScopedTypeVariables
6769 StandaloneDeriving
@@ -74,6 +76,7 @@ library
7476 exposed-modules:
7577 Development.IDE.Core.FileStore
7678 Development.IDE.Core.OfInterest
79+ Development.IDE.Core.PositionMapping
7780 Development.IDE.Core.Rules
7881 Development.IDE.Core.RuleTypes
7982 Development.IDE.Core.Service
@@ -131,3 +134,26 @@ executable hie-core
131134 RecordWildCards
132135 TupleSections
133136 ViewPatterns
137+
138+test-suite hie-core-tests
139+ type: exitcode-stdio-1.0
140+ default-language: Haskell2010
141+ build-tool-depends:
142+ hie-core:hie-core
143+ build-depends:
144+ base,
145+ containers,
146+ extra,
147+ filepath,
148+ haskell-lsp-types,
149+ lens,
150+ lsp-test,
151+ parser-combinators,
152+ tasty,
153+ tasty-hunit,
154+ text
155+ hs-source-dirs: test/cabal test/exe test/src
156+ main-is: Main.hs
157+ other-modules:
158+ Development.IDE.Test
159+ Development.IDE.Test.Runfiles
stack.yaml+2
@@ -8,6 +8,8 @@ extra-deps:
88 subdirs:
99 - .
1010 - haskell-lsp-types
11+- git: https://github.com/digital-asset/lsp-test.git
12+ commit: 50c43452e19e494d71ccba1f7922d0b3b3fc69c3
1113- git: https://github.com/mpickering/hie-bios.git
1214 commit: 8427e424a83c2f3d60bdd26c02478c00d2189a73
1315nix:
test/BUILD.bazel+16−2
@@ -27,6 +27,20 @@ da_haskell_library(
2727 ],
2828)
2929
30+da_haskell_library(
31+ name = "hie-core-test-runfiles",
32+ srcs = glob(["bazel/**/*.hs"]),
33+ hazel_deps = [
34+ "base",
35+ "filepath",
36+ ],
37+ src_strip_prefix = "bazel",
38+ visibility = ["//visibility:public"],
39+ deps = [
40+ "//libs-haskell/bazel-runfiles",
41+ ],
42+)
43+
3044da_haskell_test(
3145 name = "hie-core-tests",
3246 srcs = glob(["exe/**/*.hs"]),
@@ -43,8 +57,8 @@ da_haskell_test(
4357 ],
4458 src_strip_prefix = "exe",
4559 deps = [
60+ ":hie-core-test-runfiles",
61+ ":hie-core-testing",
4662 "//compiler/hie-core",
47− "//compiler/hie-core/test:hie-core-testing",
48− "//libs-haskell/bazel-runfiles",
4963 ],
5064)
test/bazel/Development/IDE/Test/Runfiles.hsnew file+16
@@ -0,0 +1,16 @@
1+-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2+-- SPDX-License-Identifier: Apache-2.0
3+
4+module Development.IDE.Test.Runfiles
5+ ( locateHieCoreExecutable
6+ ) where
7+
8+import System.FilePath ((</>), FilePath)
9+
10+import DA.Bazel.Runfiles
11+
12+
13+locateHieCoreExecutable :: IO FilePath
14+locateHieCoreExecutable = locateRunfiles hieCoreExePath
15+ where
16+ hieCoreExePath = mainWorkspace </> exe "compiler/hie-core/hie-core-exe"
test/cabal/Development/IDE/Test/Runfiles.hsnew file+12
@@ -0,0 +1,12 @@
1+-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2+-- SPDX-License-Identifier: Apache-2.0
3+
4+module Development.IDE.Test.Runfiles
5+ ( locateHieCoreExecutable
6+ ) where
7+
8+import System.FilePath (FilePath)
9+
10+
11+locateHieCoreExecutable :: IO FilePath
12+locateHieCoreExecutable = pure "hie-core"
test/exe/Main.hs+3−5
@@ -1,22 +1,21 @@
11-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
22-- SPDX-License-Identifier: Apache-2.0
33
4+{-# LANGUAGE DuplicateRecordFields #-}
45
56module Main (main) where
67
78import Control.Monad (void)
89import qualified Data.Text as T
910import Development.IDE.Test
11+import Development.IDE.Test.Runfiles
1012import Language.Haskell.LSP.Test
1113import Language.Haskell.LSP.Types
1214import System.Environment.Blank (setEnv)
13−import System.FilePath
1415import System.IO.Extra
1516import Test.Tasty
1617import Test.Tasty.HUnit
1718
18−import DA.Bazel.Runfiles
19−
2019
2120main :: IO ()
2221main = defaultMain $ testGroup "HIE"
@@ -60,8 +59,7 @@ testSession name = testCase name . run
6059
6160run :: Session a -> IO a
6261run s = withTempDir $ \dir -> do
63− let hieCoreExePath = mainWorkspace </> exe "compiler/hie-core/hie-core-exe"
64− hieCoreExe <- locateRunfiles hieCoreExePath
62+ hieCoreExe <- locateHieCoreExecutable
6563 let cmd = unwords [hieCoreExe, "--lsp", "--cwd", dir]
6664 -- HIE calls getXgdDirectory which assumes that HOME is set.
6765 -- Only sets HOME if it wasn't already set.