Skip to content

Commit 000a76c

Browse files
fendormergify[bot]
andauthored
Delete dead code in hls-test-utils (#3368)
* Remove dead and obsolete code * Organise export list with respect to utility functions Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 3893154 commit 000a76c

File tree

3 files changed

+20
-70
lines changed

3 files changed

+20
-70
lines changed

hls-test-utils/src/Test/Hls/Util.hs

+19-66
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,40 @@
66
{-# LANGUAGE OverloadedStrings #-}
77
{-# LANGUAGE TypeOperators #-}
88
module 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
6164
import Language.LSP.Types.Lens (textDocument)
6265
import qualified Language.LSP.Types.Lens as L
6366
import System.Directory
64-
import System.Environment
6567
import System.FilePath
6668
import System.Info.Extra (isMac, isWindows)
6769
import 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-
11895
data 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.

test/functional/FunctionalCodeAction.hs

-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ importTests = testGroup "import suggestions" [
106106
packageTests :: TestTree
107107
packageTests = testGroup "add package suggestions" [
108108
ignoreTestBecause "no support for adding dependent packages via code action" $ testCase "adds to .cabal files" $ do
109-
flushStackEnvironment
110109
runSession hlsCommand fullCaps "test/testdata/addPackageTest/cabal-exe" $ do
111110
doc <- openDoc "AddPackage.hs" "haskell"
112111

test/wrapper/Main.hs

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import System.Process
55
import Test.Hls
66

77
main :: IO ()
8-
main = do
9-
flushStackEnvironment
10-
defaultTestRunner $ testGroup "haskell-language-server-wrapper" [projectGhcVersionTests]
8+
main = defaultTestRunner $ testGroup "haskell-language-server-wrapper" [projectGhcVersionTests]
119

1210
projectGhcVersionTests :: TestTree
1311
projectGhcVersionTests = testGroup "--project-ghc-version"

0 commit comments

Comments
 (0)