Skip to content

Delete dead code in hls-test-utils #3368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 19 additions & 66 deletions hls-test-utils/src/Test/Hls/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,40 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeOperators #-}
module Test.Hls.Util
(
( -- * Test Capabilities
codeActionSupportCaps
, expectCodeAction
, dontExpectCodeAction
, expectDiagnostic
, expectNoMoreDiagnostics
, expectSameLocations
, failIfSessionTimeout
, flushStackEnvironment
, fromAction
, fromCommand
, getCompletionByLabel
-- * Environment specifications
-- for ignoring tests
, ghcVersion, GhcVersion(..)
, hostOS, OS(..)
, matchesCurrentEnv, EnvSpec(..)
, noLiteralCaps
, ignoreForGhcVersions
, ignoreInEnv
, onlyRunForGhcVersions
, inspectCodeAction
, inspectCommand
, inspectDiagnostic
, knownBrokenOnWindows
, knownBrokenForGhcVersions
, knownBrokenInEnv
, onlyWorkForGhcVersions
, setupBuildToolFiles
-- * Extract code actions
, fromAction
, fromCommand
-- * Session Assertion Helpers
, dontExpectCodeAction
, expectDiagnostic
, expectNoMoreDiagnostics
, expectSameLocations
, failIfSessionTimeout
, getCompletionByLabel
, noLiteralCaps
, inspectCodeAction
, inspectCommand
, inspectDiagnostic
, SymbolLocation
, waitForDiagnosticsFrom
, waitForDiagnosticsFromSource
, waitForDiagnosticsFromSourceWithTimeout
-- * Temporary directories
, withCurrentDirectoryInTmp
, withCurrentDirectoryInTmp'
, withCanonicalTempDir
Expand All @@ -61,7 +64,6 @@ import qualified Language.LSP.Types.Capabilities as C
import Language.LSP.Types.Lens (textDocument)
import qualified Language.LSP.Types.Lens as L
import System.Directory
import System.Environment
import System.FilePath
import System.Info.Extra (isMac, isWindows)
import qualified System.IO.Extra
Expand All @@ -87,34 +89,9 @@ codeActionSupportCaps = def & textDocument ?~ textDocumentCaps
literalSupport = CodeActionLiteralSupport def

-- ---------------------------------------------------------------------

setupBuildToolFiles :: IO ()
setupBuildToolFiles = do
forM_ files setupDirectFilesIn

setupDirectFilesIn :: FilePath -> IO ()
setupDirectFilesIn f =
writeFile (f ++ "hie.yaml") hieYamlCradleDirectContents


-- Environment specification for ignoring tests
-- ---------------------------------------------------------------------

files :: [FilePath]
files =
[ "./test/testdata/"
-- , "./test/testdata/addPackageTest/cabal-exe/"
-- , "./test/testdata/addPackageTest/hpack-exe/"
-- , "./test/testdata/addPackageTest/cabal-lib/"
-- , "./test/testdata/addPackageTest/hpack-lib/"
-- , "./test/testdata/addPragmas/"
-- , "./test/testdata/badProjects/cabal/"
-- , "./test/testdata/completion/"
-- , "./test/testdata/definition/"
-- , "./test/testdata/gototest/"
-- , "./test/testdata/redundantImportTest/"
-- , "./test/testdata/wErrorTest/"
]

data EnvSpec = HostOS OS | GhcVer GhcVersion
deriving (Show, Eq)

Expand Down Expand Up @@ -168,30 +145,6 @@ onlyRunForGhcVersions vers =

-- ---------------------------------------------------------------------

hieYamlCradleDirectContents :: String
hieYamlCradleDirectContents = unlines
[ "# WARNING: THIS FILE IS AUTOGENERATED IN test/utils/TestUtils.hs. IT WILL BE OVERWRITTEN ON EVERY TEST RUN"
, "cradle:"
, " direct:"
, " arguments:"
, " - -i."
]


-- ---------------------------------------------------------------------

flushStackEnvironment :: IO ()
flushStackEnvironment = do
-- We need to clear these environment variables to prevent
-- collisions with stack usages
-- See https://github.com/commercialhaskell/stack/issues/4875
unsetEnv "GHC_PACKAGE_PATH"
unsetEnv "GHC_ENVIRONMENT"
unsetEnv "HASKELL_PACKAGE_SANDBOX"
unsetEnv "HASKELL_PACKAGE_SANDBOXES"

-- ---------------------------------------------------------------------

-- | Like 'withCurrentDirectory', but will copy the directory over to the system
-- temporary directory first to avoid haskell-language-server's source tree from
-- interfering with the cradle.
Expand Down
1 change: 0 additions & 1 deletion test/functional/FunctionalCodeAction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ importTests = testGroup "import suggestions" [
packageTests :: TestTree
packageTests = testGroup "add package suggestions" [
ignoreTestBecause "no support for adding dependent packages via code action" $ testCase "adds to .cabal files" $ do
flushStackEnvironment
runSession hlsCommand fullCaps "test/testdata/addPackageTest/cabal-exe" $ do
doc <- openDoc "AddPackage.hs" "haskell"

Expand Down
4 changes: 1 addition & 3 deletions test/wrapper/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import System.Process
import Test.Hls

main :: IO ()
main = do
flushStackEnvironment
defaultTestRunner $ testGroup "haskell-language-server-wrapper" [projectGhcVersionTests]
main = defaultTestRunner $ testGroup "haskell-language-server-wrapper" [projectGhcVersionTests]

projectGhcVersionTests :: TestTree
projectGhcVersionTests = testGroup "--project-ghc-version"
Expand Down