66{-# LANGUAGE OverloadedStrings #-}
77{-# LANGUAGE TypeOperators #-}
88module Test.Hls.Util
9- (
9+ ( -- * Test Capabilities
1010 codeActionSupportCaps
1111 , 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
2114 , ghcVersion , GhcVersion (.. )
2215 , hostOS , OS (.. )
2316 , matchesCurrentEnv , EnvSpec (.. )
24- , noLiteralCaps
2517 , ignoreForGhcVersions
2618 , ignoreInEnv
2719 , onlyRunForGhcVersions
28- , inspectCodeAction
29- , inspectCommand
30- , inspectDiagnostic
3120 , knownBrokenOnWindows
3221 , knownBrokenForGhcVersions
3322 , knownBrokenInEnv
3423 , 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
3638 , SymbolLocation
3739 , waitForDiagnosticsFrom
3840 , waitForDiagnosticsFromSource
3941 , waitForDiagnosticsFromSourceWithTimeout
42+ -- * Temporary directories
4043 , withCurrentDirectoryInTmp
4144 , withCurrentDirectoryInTmp'
4245 , withCanonicalTempDir
@@ -61,7 +64,6 @@ import qualified Language.LSP.Types.Capabilities as C
6164import Language.LSP.Types.Lens (textDocument )
6265import qualified Language.LSP.Types.Lens as L
6366import System.Directory
64- import System.Environment
6567import System.FilePath
6668import System.Info.Extra (isMac , isWindows )
6769import qualified System.IO.Extra
@@ -87,34 +89,9 @@ codeActionSupportCaps = def & textDocument ?~ textDocumentCaps
8789 literalSupport = CodeActionLiteralSupport def
8890
8991-- ---------------------------------------------------------------------
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
10093-- ---------------------------------------------------------------------
10194
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-
11895data EnvSpec = HostOS OS | GhcVer GhcVersion
11996 deriving (Show , Eq )
12097
@@ -168,30 +145,6 @@ onlyRunForGhcVersions vers =
168145
169146-- ---------------------------------------------------------------------
170147
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-
195148-- | Like 'withCurrentDirectory', but will copy the directory over to the system
196149-- temporary directory first to avoid haskell-language-server's source tree from
197150-- interfering with the cradle.
0 commit comments