From 80cd98b1563e08e390154002f0e8ad592f3db0ab Mon Sep 17 00:00:00 2001 From: Fendor Date: Mon, 28 Nov 2022 18:17:37 +0100 Subject: [PATCH 1/2] Remove dead and obsolete code --- hls-test-utils/src/Test/Hls/Util.hs | 52 +------------------------ test/functional/FunctionalCodeAction.hs | 1 - test/wrapper/Main.hs | 4 +- 3 files changed, 2 insertions(+), 55 deletions(-) diff --git a/hls-test-utils/src/Test/Hls/Util.hs b/hls-test-utils/src/Test/Hls/Util.hs index 5ab1e093dd..74d0d1367e 100644 --- a/hls-test-utils/src/Test/Hls/Util.hs +++ b/hls-test-utils/src/Test/Hls/Util.hs @@ -61,7 +61,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 @@ -87,34 +86,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) @@ -168,30 +142,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. diff --git a/test/functional/FunctionalCodeAction.hs b/test/functional/FunctionalCodeAction.hs index b28038cc5b..c6cd481705 100644 --- a/test/functional/FunctionalCodeAction.hs +++ b/test/functional/FunctionalCodeAction.hs @@ -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" diff --git a/test/wrapper/Main.hs b/test/wrapper/Main.hs index 6c68440a5f..ca652bbf0f 100644 --- a/test/wrapper/Main.hs +++ b/test/wrapper/Main.hs @@ -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" From df07e659b347885119e41b7495005512a56284b5 Mon Sep 17 00:00:00 2001 From: Fendor Date: Mon, 28 Nov 2022 18:17:59 +0100 Subject: [PATCH 2/2] Organise export list with respect to utility functions --- hls-test-utils/src/Test/Hls/Util.hs | 33 ++++++++++++++++------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/hls-test-utils/src/Test/Hls/Util.hs b/hls-test-utils/src/Test/Hls/Util.hs index 74d0d1367e..e654ee9660 100644 --- a/hls-test-utils/src/Test/Hls/Util.hs +++ b/hls-test-utils/src/Test/Hls/Util.hs @@ -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