6
6
{-# LANGUAGE OverloadedStrings #-}
7
7
{-# LANGUAGE TypeOperators #-}
8
8
module Test.Hls.Util
9
- (
9
+ ( -- * Test Capabilities
10
10
codeActionSupportCaps
11
11
, expectCodeAction
12
- , dontExpectCodeAction
13
- , expectDiagnostic
14
- , expectNoMoreDiagnostics
15
- , expectSameLocations
16
- , failIfSessionTimeout
17
- , flushStackEnvironment
18
- , fromAction
19
- , fromCommand
20
- , getCompletionByLabel
12
+ -- * Environment specifications
13
+ -- for ignoring tests
21
14
, ghcVersion , GhcVersion (.. )
22
15
, hostOS , OS (.. )
23
16
, matchesCurrentEnv , EnvSpec (.. )
24
- , noLiteralCaps
25
17
, ignoreForGhcVersions
26
18
, ignoreInEnv
27
19
, onlyRunForGhcVersions
28
- , inspectCodeAction
29
- , inspectCommand
30
- , inspectDiagnostic
31
20
, knownBrokenOnWindows
32
21
, knownBrokenForGhcVersions
33
22
, knownBrokenInEnv
34
23
, onlyWorkForGhcVersions
35
- , setupBuildToolFiles
24
+ -- * Extract code actions
25
+ , fromAction
26
+ , fromCommand
27
+ -- * Session Assertion Helpers
28
+ , dontExpectCodeAction
29
+ , expectDiagnostic
30
+ , expectNoMoreDiagnostics
31
+ , expectSameLocations
32
+ , failIfSessionTimeout
33
+ , getCompletionByLabel
34
+ , noLiteralCaps
35
+ , inspectCodeAction
36
+ , inspectCommand
37
+ , inspectDiagnostic
36
38
, SymbolLocation
37
39
, waitForDiagnosticsFrom
38
40
, waitForDiagnosticsFromSource
39
41
, waitForDiagnosticsFromSourceWithTimeout
42
+ -- * Temporary directories
40
43
, withCurrentDirectoryInTmp
41
44
, withCurrentDirectoryInTmp'
42
45
, withCanonicalTempDir
@@ -61,7 +64,6 @@ import qualified Language.LSP.Types.Capabilities as C
61
64
import Language.LSP.Types.Lens (textDocument )
62
65
import qualified Language.LSP.Types.Lens as L
63
66
import System.Directory
64
- import System.Environment
65
67
import System.FilePath
66
68
import System.Info.Extra (isMac , isWindows )
67
69
import qualified System.IO.Extra
@@ -87,34 +89,9 @@ codeActionSupportCaps = def & textDocument ?~ textDocumentCaps
87
89
literalSupport = CodeActionLiteralSupport def
88
90
89
91
-- ---------------------------------------------------------------------
90
-
91
- setupBuildToolFiles :: IO ()
92
- setupBuildToolFiles = do
93
- forM_ files setupDirectFilesIn
94
-
95
- setupDirectFilesIn :: FilePath -> IO ()
96
- setupDirectFilesIn f =
97
- writeFile (f ++ " hie.yaml" ) hieYamlCradleDirectContents
98
-
99
-
92
+ -- Environment specification for ignoring tests
100
93
-- ---------------------------------------------------------------------
101
94
102
- files :: [FilePath ]
103
- files =
104
- [ " ./test/testdata/"
105
- -- , "./test/testdata/addPackageTest/cabal-exe/"
106
- -- , "./test/testdata/addPackageTest/hpack-exe/"
107
- -- , "./test/testdata/addPackageTest/cabal-lib/"
108
- -- , "./test/testdata/addPackageTest/hpack-lib/"
109
- -- , "./test/testdata/addPragmas/"
110
- -- , "./test/testdata/badProjects/cabal/"
111
- -- , "./test/testdata/completion/"
112
- -- , "./test/testdata/definition/"
113
- -- , "./test/testdata/gototest/"
114
- -- , "./test/testdata/redundantImportTest/"
115
- -- , "./test/testdata/wErrorTest/"
116
- ]
117
-
118
95
data EnvSpec = HostOS OS | GhcVer GhcVersion
119
96
deriving (Show , Eq )
120
97
@@ -168,30 +145,6 @@ onlyRunForGhcVersions vers =
168
145
169
146
-- ---------------------------------------------------------------------
170
147
171
- hieYamlCradleDirectContents :: String
172
- hieYamlCradleDirectContents = unlines
173
- [ " # WARNING: THIS FILE IS AUTOGENERATED IN test/utils/TestUtils.hs. IT WILL BE OVERWRITTEN ON EVERY TEST RUN"
174
- , " cradle:"
175
- , " direct:"
176
- , " arguments:"
177
- , " - -i."
178
- ]
179
-
180
-
181
- -- ---------------------------------------------------------------------
182
-
183
- flushStackEnvironment :: IO ()
184
- flushStackEnvironment = do
185
- -- We need to clear these environment variables to prevent
186
- -- collisions with stack usages
187
- -- See https://github.com/commercialhaskell/stack/issues/4875
188
- unsetEnv " GHC_PACKAGE_PATH"
189
- unsetEnv " GHC_ENVIRONMENT"
190
- unsetEnv " HASKELL_PACKAGE_SANDBOX"
191
- unsetEnv " HASKELL_PACKAGE_SANDBOXES"
192
-
193
- -- ---------------------------------------------------------------------
194
-
195
148
-- | Like 'withCurrentDirectory', but will copy the directory over to the system
196
149
-- temporary directory first to avoid haskell-language-server's source tree from
197
150
-- interfering with the cradle.
0 commit comments