diff --git a/.circleci/config.yml b/.circleci/config.yml index 715de0f01f..b9702220fa 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -38,7 +38,7 @@ defaults: &defaults - run: name: Build Testsuite without running it - command: stack --stack-yaml=${STACK_FILE} build --test --no-run-tests + command: stack -j 1 --stack-yaml=${STACK_FILE} build --test --no-run-tests no_output_timeout: 30m - store_artifacts: @@ -52,14 +52,6 @@ defaults: &defaults - ~/build/.stack-work - ~/build/ghcide/.stack-work - - run: - name: Setup stack eval hie.html - command: cp plugins/hls-eval-plugin/test/testdata/hie-stack.yaml plugins/hls-eval-plugin/test/testdata/hie.yaml - - - run: - name: Setup stack eval stack.html - command: grep '^resolver:\|^compiler:' stack-build.txt > plugins/hls-eval-plugin/test/testdata/stack.yaml - - run: name: Build including tests command: stack --stack-yaml=${STACK_FILE} test --no-run-tests diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 44d0d90e3e..51c31323ee 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -131,27 +131,30 @@ jobs: # instances to be spun up for the poor github actions runner to handle run: cabal test wrapper-test --test-options="-j1" || cabal test wrapper-test --test-options="-j1" || cabal test wrapper-test --test-options="-j1" - - name: Test hls-tactics-plugin test suite + - name: Test hls-brittany-plugin if: ${{ matrix.test }} - run: LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-tactics-plugin --test-options="-j1" + run: cabal test hls-brittany-plugin || cabal test hls-brittany-plugin --test-options="-j1" - - name: Test brittany plugin + - name: Test hls-class-plugin if: ${{ matrix.test }} - env: - HLS_TEST_EXE: hls - HLS_WRAPPER_TEST_EXE: hls-wrapper - run: cabal test hls-brittany-plugin || cabal test hls-brittany-plugin --test-options="-j1" + run: cabal test hls-class-plugin || cabal test hls-class-plugin --test-options="-j1" - - name: Test stylish-haskell plugin + - name: Test hls-eval-plugin + if: ${{ matrix.test }} + run: cabal test hls-eval-plugin --test-options="-j1 --rerun" || cabal test hls-eval-plugin --test-options="-j1 --rerun" + + - name: Test hls-haddock-comments-plugin + if: ${{ matrix.test }} + run: cabal test hls-haddock-comments-plugin || cabal test hls-haddock-comments-plugin --test-options="-j1" + + - name: Test hls-splice-plugin + if: ${{ matrix.test }} + run: cabal test hls-splice-plugin || cabal test hls-splice-plugin --test-options="-j1" + + - name: Test hls-stylish-haskell-plugin if: ${{ matrix.test }} - env: - HLS_TEST_EXE: hls - HLS_WRAPPER_TEST_EXE: hls-wrapper run: cabal test hls-stylish-haskell-plugin || cabal test hls-stylish-haskell-plugin --test-options="-j1" - - name: Test eval plugin + - name: Test hls-tactics-plugin test suite if: ${{ matrix.test }} - env: - HLS_TEST_EXE: hls - HLS_WRAPPER_TEST_EXE: hls-wrapper - run: cabal test hls-eval-plugin || cabal test hls-eval-plugin --test-options="-j1" + run: LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-tactics-plugin --test-options="-j1" diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 37e87c4b31..2e3c50f9e0 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -27,7 +27,6 @@ extra-source-files: test/testdata/**/*.h test/testdata/**/*.hs test/testdata/**/*.expected - test/testdata/**/*.error flag pedantic description: Enable -Werror @@ -394,11 +393,10 @@ test-suite func-test , containers , unordered-containers - hs-source-dirs: test/functional plugins/hls-splice-plugin/src + hs-source-dirs: test/functional test/utils main-is: Main.hs other-modules: - Class Command Completion Config @@ -417,9 +415,7 @@ test-suite func-test Rename Symbol TypeDefinition - Splice - HaddockComments - Ide.Plugin.Splice.Types + Test.Hls.Command default-extensions: OverloadedStrings ghc-options: diff --git a/hls-plugin-api/hls-plugin-api.cabal b/hls-plugin-api/hls-plugin-api.cabal index 6c6f48319b..ef91e712e4 100644 --- a/hls-plugin-api/hls-plugin-api.cabal +++ b/hls-plugin-api/hls-plugin-api.cabal @@ -1,4 +1,4 @@ -cabal-version: 2.2 +cabal-version: 2.4 name: hls-plugin-api version: 1.1.0.0 synopsis: Haskell Language Server API for plugin communication diff --git a/hls-test-utils/hls-test-utils.cabal b/hls-test-utils/hls-test-utils.cabal index bf99a88ee7..8e9dc107ff 100644 --- a/hls-test-utils/hls-test-utils.cabal +++ b/hls-test-utils/hls-test-utils.cabal @@ -1,4 +1,4 @@ -cabal-version: 2.2 +cabal-version: 2.4 name: hls-test-utils version: 1.0.0.0 synopsis: Utilities used in the tests of Haskell Language Server diff --git a/hls-test-utils/src/Test/Hls/Util.hs b/hls-test-utils/src/Test/Hls/Util.hs index 0b64ea7338..8573089847 100644 --- a/hls-test-utils/src/Test/Hls/Util.hs +++ b/hls-test-utils/src/Test/Hls/Util.hs @@ -15,9 +15,6 @@ module Test.Hls.Util , ghcVersion, GhcVersion(..) , hostOS, OS(..) , matchesCurrentEnv, EnvSpec(..) - , hlsCommand - , hlsCommandExamplePlugin - , hlsCommandVomit , ignoreForGhcVersions , ignoreInEnv , inspectCodeAction @@ -26,7 +23,6 @@ module Test.Hls.Util , knownBrokenOnWindows , knownBrokenForGhcVersions , knownBrokenInEnv - , logFilePath , setupBuildToolFiles , SymbolLocation , waitForDiagnosticsFrom @@ -57,7 +53,6 @@ import System.Environment import System.Time.Extra (Seconds, sleep) import System.FilePath import System.IO.Temp -import System.IO.Unsafe import Test.Hspec.Runner import Test.Hspec.Core.Formatters hiding (Seconds) import Test.Tasty (TestTree) @@ -164,26 +159,6 @@ ignoreForGhcVersions vers reason | ghcVersion `elem` vers = ignoreTestBecause reason | otherwise = id -logFilePath :: String -logFilePath = "hls-" ++ show ghcVersion ++ ".log" - --- | The command to execute the version of hls for the current compiler. --- --- Both @stack test@ and @cabal new-test@ setup the environment so @hls@ is --- on PATH. Cabal seems to respond to @build-tool-depends@ specifically while --- stack just puts all project executables on PATH. -hlsCommand :: String -{-# NOINLINE hlsCommand #-} -hlsCommand = unsafePerformIO $ do - testExe <- fromMaybe "haskell-language-server" <$> lookupEnv "HLS_TEST_EXE" - pure $ testExe ++ " --lsp -d -j2 -l test-logs/" ++ logFilePath - -hlsCommandVomit :: String -hlsCommandVomit = hlsCommand ++ " --vomit" - -hlsCommandExamplePlugin :: String -hlsCommandExamplePlugin = hlsCommand ++ " --example" - -- --------------------------------------------------------------------- hieYamlCradleDirectContents :: String diff --git a/plugins/hls-class-plugin/hls-class-plugin.cabal b/plugins/hls-class-plugin/hls-class-plugin.cabal index 5c8e576681..45433bd2a0 100644 --- a/plugins/hls-class-plugin/hls-class-plugin.cabal +++ b/plugins/hls-class-plugin/hls-class-plugin.cabal @@ -1,10 +1,13 @@ -cabal-version: 2.2 +cabal-version: 2.4 name: hls-class-plugin version: 1.0.0.0 -synopsis: Class/instance management plugin for Haskell Language Server +synopsis: + Class/instance management plugin for Haskell Language Server + description: - Class/instance management plugin for Haskell Language Server. - For usage, please see README of HLS on GitHub at + Class/instance management plugin for Haskell Language Server. + For usage, please see README of HLS on GitHub at + license: Apache-2.0 license-file: LICENSE author: Junyoung Clare Jang @@ -13,24 +16,60 @@ homepage: https://github.com/haskell/haskell-language-server#readme bug-reports: https://github.com/haskell/haskell-language-server/issues category: Development build-type: Simple +extra-source-files: + LICENSE + test/testdata/*.hs library - exposed-modules: Ide.Plugin.Class - hs-source-dirs: src - build-depends: aeson - , base >=4.12 && <5 - , containers - , lsp - , hls-plugin-api >= 1.0 && < 1.2 - , ghc - , ghc-exactprint - , ghcide ^>= 1.1.0.0 - , lens - , shake - , text - , transformers - , unordered-containers + exposed-modules: Ide.Plugin.Class + hs-source-dirs: src + build-depends: + , aeson + , base >=4.12 && <5 + , containers + , ghc + , ghc-exactprint + , ghcide ^>=1.1.0.0 + , hls-plugin-api >=1.0 && <1.2 + , lens + , lsp + , shake + , text + , transformers + , unordered-containers + + default-language: Haskell2010 + default-extensions: + DataKinds + TypeOperators + ghc-options: -Wno-unticked-promoted-constructors + +executable test-server default-language: Haskell2010 - default-extensions: DataKinds, TypeOperators - ghc-options: -Wno-unticked-promoted-constructors + build-depends: + , base + , data-default + , ghcide + , hls-class-plugin + , hls-plugin-api + + main-is: Server.hs + hs-source-dirs: test + ghc-options: -threaded + +test-suite tests + type: exitcode-stdio-1.0 + default-language: Haskell2010 + build-tool-depends: hls-class-plugin:test-server -any + hs-source-dirs: test + main-is: Main.hs + build-depends: + , base + , bytestring + , filepath + , hls-test-utils + , lens + , lsp-test + , lsp-types + , text diff --git a/test/functional/Class.hs b/plugins/hls-class-plugin/test/Main.hs similarity index 91% rename from test/functional/Class.hs rename to plugins/hls-class-plugin/test/Main.hs index 65658c464f..af8495e46b 100644 --- a/test/functional/Class.hs +++ b/plugins/hls-class-plugin/test/Main.hs @@ -2,8 +2,8 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeOperators #-} -module Class - ( tests +module Main + ( main ) where @@ -14,11 +14,14 @@ import qualified Language.LSP.Types.Lens as J import System.FilePath import Test.Hls +main :: IO () +main = defaultTestRunner tests + tests :: TestTree tests = testGroup "class" [ testCase "Produces addMinimalMethodPlaceholders code actions for one instance" $ do - runSession hlsCommand fullCaps classPath $ do + runSession testCommand fullCaps classPath $ do doc <- openDoc "T1.hs" "haskell" _ <- waitForDiagnosticsFromSource doc "typecheck" caResults <- getAllCodeActions doc @@ -26,7 +29,6 @@ tests = testGroup @?= [ Just "Add placeholders for '=='" , Just "Add placeholders for '/='" - , Just "Disable \"missing-methods\" warnings" ] , glodenTest "Creates a placeholder for '=='" "T1" "eq" $ \(eqAction:_) -> do @@ -54,12 +56,12 @@ _CACodeAction = prism' InR $ \case _ -> Nothing classPath :: FilePath -classPath = "test" "testdata" "class" +classPath = "test" "testdata" glodenTest :: String -> FilePath -> FilePath -> ([CodeAction] -> Session ()) -> TestTree glodenTest name fp deco execute = goldenGitDiff name (classPath fpWithDeco <.> "expected" <.> "hs") - $ runSession hlsCommand fullCaps classPath + $ runSession testCommand fullCaps classPath $ do doc <- openDoc (fp <.> "hs") "haskell" _ <- waitForDiagnosticsFromSource doc "typecheck" diff --git a/plugins/hls-class-plugin/test/Server.hs b/plugins/hls-class-plugin/test/Server.hs new file mode 100644 index 0000000000..584c52cd1b --- /dev/null +++ b/plugins/hls-class-plugin/test/Server.hs @@ -0,0 +1,18 @@ + +{-# LANGUAGE OverloadedStrings #-} +module Main(main) where + +import Data.Default +import Development.IDE.Main +import qualified Development.IDE.Plugin.HLS.GhcIde as Ghcide +import qualified Ide.Plugin.Class as Class +import Ide.Plugin.Config +import Ide.PluginUtils + +main :: IO () +main = defaultMain def + { argsHlsPlugins = pluginDescToIdePlugins $ + [ Class.descriptor "class" + ] <> + Ghcide.descriptors + } diff --git a/test/testdata/class/T1.eq.expected.hs b/plugins/hls-class-plugin/test/testdata/T1.eq.expected.hs similarity index 100% rename from test/testdata/class/T1.eq.expected.hs rename to plugins/hls-class-plugin/test/testdata/T1.eq.expected.hs diff --git a/test/testdata/class/T1.hs b/plugins/hls-class-plugin/test/testdata/T1.hs similarity index 100% rename from test/testdata/class/T1.hs rename to plugins/hls-class-plugin/test/testdata/T1.hs diff --git a/test/testdata/class/T1.ne.expected.hs b/plugins/hls-class-plugin/test/testdata/T1.ne.expected.hs similarity index 100% rename from test/testdata/class/T1.ne.expected.hs rename to plugins/hls-class-plugin/test/testdata/T1.ne.expected.hs diff --git a/test/testdata/class/T2.fmap.expected.hs b/plugins/hls-class-plugin/test/testdata/T2.fmap.expected.hs similarity index 100% rename from test/testdata/class/T2.fmap.expected.hs rename to plugins/hls-class-plugin/test/testdata/T2.fmap.expected.hs diff --git a/test/testdata/class/T2.hs b/plugins/hls-class-plugin/test/testdata/T2.hs similarity index 100% rename from test/testdata/class/T2.hs rename to plugins/hls-class-plugin/test/testdata/T2.hs diff --git a/test/testdata/class/T3.1.expected.hs b/plugins/hls-class-plugin/test/testdata/T3.1.expected.hs similarity index 100% rename from test/testdata/class/T3.1.expected.hs rename to plugins/hls-class-plugin/test/testdata/T3.1.expected.hs diff --git a/test/testdata/class/T3.2.expected.hs b/plugins/hls-class-plugin/test/testdata/T3.2.expected.hs similarity index 100% rename from test/testdata/class/T3.2.expected.hs rename to plugins/hls-class-plugin/test/testdata/T3.2.expected.hs diff --git a/test/testdata/class/T3.hs b/plugins/hls-class-plugin/test/testdata/T3.hs similarity index 100% rename from test/testdata/class/T3.hs rename to plugins/hls-class-plugin/test/testdata/T3.hs diff --git a/test/testdata/class/T4.expected.hs b/plugins/hls-class-plugin/test/testdata/T4.expected.hs similarity index 100% rename from test/testdata/class/T4.expected.hs rename to plugins/hls-class-plugin/test/testdata/T4.expected.hs diff --git a/test/testdata/class/T4.hs b/plugins/hls-class-plugin/test/testdata/T4.hs similarity index 100% rename from test/testdata/class/T4.hs rename to plugins/hls-class-plugin/test/testdata/T4.hs diff --git a/plugins/hls-eval-plugin/hls-eval-plugin.cabal b/plugins/hls-eval-plugin/hls-eval-plugin.cabal index 30a8512d24..7b2dcaf957 100644 --- a/plugins/hls-eval-plugin/hls-eval-plugin.cabal +++ b/plugins/hls-eval-plugin/hls-eval-plugin.cabal @@ -111,7 +111,6 @@ test-suite tests build-tool-depends: hls-eval-plugin:test-server -any hs-source-dirs: test main-is: Main.hs - ghc-options: -Wunused-packages build-depends: , aeson diff --git a/plugins/hls-eval-plugin/test/Main.hs b/plugins/hls-eval-plugin/test/Main.hs index 8a09126edd..3cc5935601 100644 --- a/plugins/hls-eval-plugin/test/Main.hs +++ b/plugins/hls-eval-plugin/test/Main.hs @@ -213,4 +213,4 @@ replaceUnicodeQuotes :: T.Text -> T.Text replaceUnicodeQuotes = T.replace "‘" "'" . T.replace "’" "'" evalPath :: FilePath -evalPath = "test/testdata" +evalPath = "test" "testdata" diff --git a/plugins/hls-eval-plugin/test/testdata/hie-cabal.yaml b/plugins/hls-eval-plugin/test/testdata/hie-cabal.yaml deleted file mode 100644 index 7251e586cd..0000000000 --- a/plugins/hls-eval-plugin/test/testdata/hie-cabal.yaml +++ /dev/null @@ -1,4 +0,0 @@ -cradle: - cabal: - - path: "././" - component: "lib:test" diff --git a/plugins/hls-eval-plugin/test/testdata/hie-stack.yaml b/plugins/hls-eval-plugin/test/testdata/hie-stack.yaml deleted file mode 100644 index 59c739536a..0000000000 --- a/plugins/hls-eval-plugin/test/testdata/hie-stack.yaml +++ /dev/null @@ -1,4 +0,0 @@ -cradle: - stack: - - path: "././" - component: "test:lib" diff --git a/plugins/hls-eval-plugin/test/testdata/stack.yaml b/plugins/hls-eval-plugin/test/testdata/stack.yaml deleted file mode 100644 index ca2bb68516..0000000000 --- a/plugins/hls-eval-plugin/test/testdata/stack.yaml +++ /dev/null @@ -1,4 +0,0 @@ -resolver: lts-14.27 # Last 8.6.5 - -packages: - - . diff --git a/plugins/hls-haddock-comments-plugin/hls-haddock-comments-plugin.cabal b/plugins/hls-haddock-comments-plugin/hls-haddock-comments-plugin.cabal index 0a0401a351..d799118cc1 100644 --- a/plugins/hls-haddock-comments-plugin/hls-haddock-comments-plugin.cabal +++ b/plugins/hls-haddock-comments-plugin/hls-haddock-comments-plugin.cabal @@ -1,33 +1,67 @@ -cabal-version: 2.2 -name: hls-haddock-comments-plugin -version: 1.0.0.0 -synopsis: Haddock comments plugin for Haskell Language Server +cabal-version: 2.4 +name: hls-haddock-comments-plugin +version: 1.0.0.0 +synopsis: Haddock comments plugin for Haskell Language Server description: Please see the README on GitHub at -license: Apache-2.0 -license-file: LICENSE -author: Potato Hatsue -maintainer: berberman@yandex.com -category: Development -build-type: Simple -homepage: https://github.com/haskell/haskell-language-server -bug-reports: https://github.com/haskell/haskell-language-server/issues +license: Apache-2.0 +license-file: LICENSE +author: Potato Hatsue +maintainer: berberman@yandex.com +category: Development +build-type: Simple +homepage: https://github.com/haskell/haskell-language-server +bug-reports: https://github.com/haskell/haskell-language-server/issues +extra-source-files: + LICENSE + test/testdata/*.hs library - exposed-modules: Ide.Plugin.HaddockComments - hs-source-dirs: src - ghc-options: -Wall -Wno-name-shadowing -Wredundant-constraints -Wno-unticked-promoted-constructors + exposed-modules: Ide.Plugin.HaddockComments + hs-source-dirs: src + ghc-options: + -Wall -Wno-name-shadowing -Wredundant-constraints + -Wno-unticked-promoted-constructors + build-depends: - , base >=4.12 && <5 + , base >=4.12 && <5 , containers , ghc , ghc-exactprint - , ghcide ^>= 1.1.0.0 + , ghcide ^>=1.1.0.0 + , hls-plugin-api >=1.0 && <1.2 , lsp-types - , hls-plugin-api >= 1.0 && < 1.2 , text , unordered-containers + default-language: Haskell2010 + default-extensions: + DataKinds + TypeOperators + +executable test-server default-language: Haskell2010 - default-extensions: DataKinds, TypeOperators + build-depends: + , base + , data-default + , ghcide + , hls-haddock-comments-plugin + , hls-plugin-api + + main-is: Server.hs + hs-source-dirs: test + ghc-options: -threaded + +test-suite tests + type: exitcode-stdio-1.0 + default-language: Haskell2010 + build-tool-depends: hls-haddock-comments-plugin:test-server -any + hs-source-dirs: test + main-is: Main.hs + build-depends: + , base + , bytestring + , filepath + , hls-test-utils + , text diff --git a/test/functional/HaddockComments.hs b/plugins/hls-haddock-comments-plugin/test/Main.hs similarity index 89% rename from test/functional/HaddockComments.hs rename to plugins/hls-haddock-comments-plugin/test/Main.hs index 6b3b0cdff3..b1ad5d8454 100644 --- a/test/functional/HaddockComments.hs +++ b/plugins/hls-haddock-comments-plugin/test/Main.hs @@ -6,8 +6,8 @@ {-# LANGUAGE TypeOperators #-} {-# LANGUAGE ViewPatterns #-} -module HaddockComments - ( tests, +module Main + ( main, ) where @@ -19,6 +19,9 @@ import Data.Text.Encoding (encodeUtf8) import System.FilePath ((<.>), ()) import Test.Hls +main :: IO () +main = defaultTestRunner tests + tests :: TestTree tests = testGroup @@ -35,9 +38,8 @@ tests = goldenTest :: FilePath -> GenCommentsType -> Int -> Int -> TestTree goldenTest fp (toTitle -> expectedTitle) l c = goldenGitDiff (fp <> " (golden)") goldenFilePath $ - runSession hlsCommand fullCaps haddockCommentsPath $ do + runSession testCommand fullCaps haddockCommentsPath $ do doc <- openDoc hsFilePath "haskell" - _ <- waitForDiagnostics actions <- getCodeActions doc (Range (Position l c) (Position l $ succ c)) case find ((== Just expectedTitle) . caTitle) actions of Just (InR x) -> do @@ -50,9 +52,8 @@ goldenTest fp (toTitle -> expectedTitle) l c = goldenGitDiff (fp <> " (golden)") expectedNothing :: FilePath -> GenCommentsType -> Int -> Int -> TestTree expectedNothing fp (toTitle -> expectedTitle) l c = testCase fp $ - runSession hlsCommand fullCaps haddockCommentsPath $ do + runSession testCommand fullCaps haddockCommentsPath $ do doc <- openDoc (fp <.> "hs") "haskell" - _ <- waitForDiagnostics titles <- mapMaybe caTitle <$> getCodeActions doc (Range (Position l c) (Position l $ succ c)) liftIO $ expectedTitle `notElem` titles @? "Unexpected CodeAction" @@ -67,5 +68,5 @@ caTitle (InR CodeAction {_title}) = Just _title caTitle _ = Nothing haddockCommentsPath :: String -haddockCommentsPath = "test" "testdata" "haddockComments" +haddockCommentsPath = "test" "testdata" diff --git a/plugins/hls-haddock-comments-plugin/test/Server.hs b/plugins/hls-haddock-comments-plugin/test/Server.hs new file mode 100644 index 0000000000..1bb10f0abd --- /dev/null +++ b/plugins/hls-haddock-comments-plugin/test/Server.hs @@ -0,0 +1,18 @@ + +{-# LANGUAGE OverloadedStrings #-} +module Main(main) where + +import Data.Default +import Development.IDE.Main +import qualified Development.IDE.Plugin.HLS.GhcIde as Ghcide +import Ide.Plugin.Config +import qualified Ide.Plugin.HaddockComments as HaddockComments +import Ide.PluginUtils + +main :: IO () +main = defaultMain def + { argsHlsPlugins = pluginDescToIdePlugins $ + [ HaddockComments.descriptor "haddockComments" + ] <> + Ghcide.descriptors + } diff --git a/test/testdata/haddockComments/ConstFunction.hs b/plugins/hls-haddock-comments-plugin/test/testdata/ConstFunction.hs similarity index 100% rename from test/testdata/haddockComments/ConstFunction.hs rename to plugins/hls-haddock-comments-plugin/test/testdata/ConstFunction.hs diff --git a/test/testdata/haddockComments/HigherRankFunction.expected.hs b/plugins/hls-haddock-comments-plugin/test/testdata/HigherRankFunction.expected.hs similarity index 100% rename from test/testdata/haddockComments/HigherRankFunction.expected.hs rename to plugins/hls-haddock-comments-plugin/test/testdata/HigherRankFunction.expected.hs diff --git a/test/testdata/haddockComments/HigherRankFunction.hs b/plugins/hls-haddock-comments-plugin/test/testdata/HigherRankFunction.hs similarity index 100% rename from test/testdata/haddockComments/HigherRankFunction.hs rename to plugins/hls-haddock-comments-plugin/test/testdata/HigherRankFunction.hs diff --git a/test/testdata/haddockComments/KindSigFunction.expected.hs b/plugins/hls-haddock-comments-plugin/test/testdata/KindSigFunction.expected.hs similarity index 100% rename from test/testdata/haddockComments/KindSigFunction.expected.hs rename to plugins/hls-haddock-comments-plugin/test/testdata/KindSigFunction.expected.hs diff --git a/test/testdata/haddockComments/KindSigFunction.hs b/plugins/hls-haddock-comments-plugin/test/testdata/KindSigFunction.hs similarity index 100% rename from test/testdata/haddockComments/KindSigFunction.hs rename to plugins/hls-haddock-comments-plugin/test/testdata/KindSigFunction.hs diff --git a/test/testdata/haddockComments/MultivariateFunction.expected.hs b/plugins/hls-haddock-comments-plugin/test/testdata/MultivariateFunction.expected.hs similarity index 100% rename from test/testdata/haddockComments/MultivariateFunction.expected.hs rename to plugins/hls-haddock-comments-plugin/test/testdata/MultivariateFunction.expected.hs diff --git a/test/testdata/haddockComments/MultivariateFunction.hs b/plugins/hls-haddock-comments-plugin/test/testdata/MultivariateFunction.hs similarity index 100% rename from test/testdata/haddockComments/MultivariateFunction.hs rename to plugins/hls-haddock-comments-plugin/test/testdata/MultivariateFunction.hs diff --git a/test/testdata/haddockComments/QualFunction.expected.hs b/plugins/hls-haddock-comments-plugin/test/testdata/QualFunction.expected.hs similarity index 100% rename from test/testdata/haddockComments/QualFunction.expected.hs rename to plugins/hls-haddock-comments-plugin/test/testdata/QualFunction.expected.hs diff --git a/test/testdata/haddockComments/QualFunction.hs b/plugins/hls-haddock-comments-plugin/test/testdata/QualFunction.hs similarity index 100% rename from test/testdata/haddockComments/QualFunction.hs rename to plugins/hls-haddock-comments-plugin/test/testdata/QualFunction.hs diff --git a/test/testdata/haddockComments/Record.expected.hs b/plugins/hls-haddock-comments-plugin/test/testdata/Record.expected.hs similarity index 100% rename from test/testdata/haddockComments/Record.expected.hs rename to plugins/hls-haddock-comments-plugin/test/testdata/Record.expected.hs diff --git a/test/testdata/haddockComments/Record.hs b/plugins/hls-haddock-comments-plugin/test/testdata/Record.hs similarity index 100% rename from test/testdata/haddockComments/Record.hs rename to plugins/hls-haddock-comments-plugin/test/testdata/Record.hs diff --git a/test/testdata/haddockComments/StaleFunction.hs b/plugins/hls-haddock-comments-plugin/test/testdata/StaleFunction.hs similarity index 100% rename from test/testdata/haddockComments/StaleFunction.hs rename to plugins/hls-haddock-comments-plugin/test/testdata/StaleFunction.hs diff --git a/test/testdata/haddockComments/StaleRecord.hs b/plugins/hls-haddock-comments-plugin/test/testdata/StaleRecord.hs similarity index 100% rename from test/testdata/haddockComments/StaleRecord.hs rename to plugins/hls-haddock-comments-plugin/test/testdata/StaleRecord.hs diff --git a/plugins/hls-splice-plugin/hls-splice-plugin.cabal b/plugins/hls-splice-plugin/hls-splice-plugin.cabal index 52d3a46efd..fbefeebda2 100644 --- a/plugins/hls-splice-plugin/hls-splice-plugin.cabal +++ b/plugins/hls-splice-plugin/hls-splice-plugin.cabal @@ -1,39 +1,86 @@ -cabal-version: 2.2 +cabal-version: 2.4 name: hls-splice-plugin version: 1.0.0.0 -synopsis: HLS Plugin to expand TemplateHaskell Splices and QuasiQuotes -description: HLS Plugin to expand TemplateHaskell Splices and QuasiQuotes. +synopsis: + HLS Plugin to expand TemplateHaskell Splices and QuasiQuotes + +description: + HLS Plugin to expand TemplateHaskell Splices and QuasiQuotes. + license: Apache-2.0 license-file: LICENSE -author: https://github.com/haskell/haskell-language-server/contributors -maintainer: https://github.com/haskell/haskell-language-server/contributors +author: + https://github.com/haskell/haskell-language-server/contributors + +maintainer: + https://github.com/haskell/haskell-language-server/contributors + category: Development build-type: Simple +extra-source-files: + LICENSE + test/testdata/*.expected + test/testdata/*.error + test/testdata/*.hs + test/testdata/*.yaml library - exposed-modules: Ide.Plugin.Splice - ghc-options: -Wall -Wno-unticked-promoted-constructors - other-modules: Ide.Plugin.Splice.Types - hs-source-dirs: src - build-depends: aeson - , base >=4.12 && <5 - , containers - , extra - , foldl - , lsp - , hls-plugin-api >= 1.0 && < 1.2 - , ghc - , ghc-exactprint - , ghcide ^>= 1.1.0.0 - , lens - , dlist - , retrie - , shake - , syb - , text - , transformers - , unordered-containers - , unliftio-core + exposed-modules: + Ide.Plugin.Splice + Ide.Plugin.Splice.Types + ghc-options: -Wall -Wno-unticked-promoted-constructors + hs-source-dirs: src + build-depends: + , aeson + , base >=4.12 && <5 + , containers + , dlist + , extra + , foldl + , ghc + , ghc-exactprint + , ghcide ^>=1.1.0.0 + , hls-plugin-api >=1.0 && <1.2 + , lens + , lsp + , retrie + , shake + , syb + , text + , transformers + , unliftio-core + , unordered-containers + + default-language: Haskell2010 + default-extensions: + DataKinds + TypeOperators + +executable test-server default-language: Haskell2010 - default-extensions: DataKinds, TypeOperators + build-depends: + , base + , data-default + , ghcide + , hls-plugin-api + , hls-splice-plugin + + main-is: Server.hs + hs-source-dirs: test + ghc-options: -threaded + +test-suite tests + type: exitcode-stdio-1.0 + default-language: Haskell2010 + build-tool-depends: hls-splice-plugin:test-server -any + hs-source-dirs: test + main-is: Main.hs + build-depends: + , base + , directory + , extra + , filepath + , hls-splice-plugin + , hls-test-utils + , text diff --git a/test/functional/Splice.hs b/plugins/hls-splice-plugin/test/Main.hs similarity index 96% rename from test/functional/Splice.hs rename to plugins/hls-splice-plugin/test/Main.hs index 7f17cab0ca..78304cccd6 100644 --- a/test/functional/Splice.hs +++ b/plugins/hls-splice-plugin/test/Main.hs @@ -6,7 +6,7 @@ {-# LANGUAGE TypeOperators #-} {-# LANGUAGE ViewPatterns #-} -module Splice (tests) where +module Main (main) where import Control.Monad import Data.List (find) @@ -19,6 +19,9 @@ import System.FilePath import System.Time.Extra (sleep) import Test.Hls +main :: IO () +main = defaultTestRunner tests + tests :: TestTree tests = testGroup @@ -61,7 +64,7 @@ tests = goldenTest :: FilePath -> ExpandStyle -> Int -> Int -> TestTree goldenTest input tc line col = testCase (input <> " (golden)") $ do - runSession hlsCommand fullCaps spliceTestPath $ do + runSession testCommand fullCaps spliceTestPath $ do doc <- openDoc input "haskell" _ <- waitForDiagnostics actions <- getCodeActions doc $ pointRange line col @@ -83,7 +86,7 @@ goldenTest input tc line col = goldenTestWithEdit :: FilePath -> ExpandStyle -> Int -> Int -> TestTree goldenTestWithEdit input tc line col = testCase (input <> " (golden)") $ do - runSession hlsCommand fullCaps spliceTestPath $ do + runSession testCommand fullCaps spliceTestPath $ do doc <- openDoc input "haskell" orig <- documentContents doc let lns = T.lines orig @@ -114,7 +117,7 @@ goldenTestWithEdit input tc line col = _ -> liftIO $ assertFailure "No CodeAction detected" spliceTestPath :: FilePath -spliceTestPath = "test/testdata/splice" +spliceTestPath = "test" "testdata" pointRange :: Int -> Int -> Range pointRange diff --git a/plugins/hls-splice-plugin/test/Server.hs b/plugins/hls-splice-plugin/test/Server.hs new file mode 100644 index 0000000000..3bf0d1460c --- /dev/null +++ b/plugins/hls-splice-plugin/test/Server.hs @@ -0,0 +1,17 @@ +{-# LANGUAGE OverloadedStrings #-} +module Main(main) where + +import Data.Default +import Development.IDE.Main +import qualified Development.IDE.Plugin.HLS.GhcIde as Ghcide +import Ide.Plugin.Config +import qualified Ide.Plugin.Splice as Splice +import Ide.PluginUtils + +main :: IO () +main = defaultMain def + { argsHlsPlugins = pluginDescToIdePlugins $ + [ Splice.descriptor "splice" + ] <> + Ghcide.descriptors + } diff --git a/test/testdata/splice/QQ.hs b/plugins/hls-splice-plugin/test/testdata/QQ.hs similarity index 100% rename from test/testdata/splice/QQ.hs rename to plugins/hls-splice-plugin/test/testdata/QQ.hs diff --git a/test/testdata/splice/TDeclKindError.hs b/plugins/hls-splice-plugin/test/testdata/TDeclKindError.hs similarity index 100% rename from test/testdata/splice/TDeclKindError.hs rename to plugins/hls-splice-plugin/test/testdata/TDeclKindError.hs diff --git a/test/testdata/splice/TDeclKindError.hs.error b/plugins/hls-splice-plugin/test/testdata/TDeclKindError.hs.error similarity index 100% rename from test/testdata/splice/TDeclKindError.hs.error rename to plugins/hls-splice-plugin/test/testdata/TDeclKindError.hs.error diff --git a/test/testdata/splice/TDeclKindError.hs.expected b/plugins/hls-splice-plugin/test/testdata/TDeclKindError.hs.expected similarity index 100% rename from test/testdata/splice/TDeclKindError.hs.expected rename to plugins/hls-splice-plugin/test/testdata/TDeclKindError.hs.expected diff --git a/test/testdata/splice/TErrorExp.hs b/plugins/hls-splice-plugin/test/testdata/TErrorExp.hs similarity index 100% rename from test/testdata/splice/TErrorExp.hs rename to plugins/hls-splice-plugin/test/testdata/TErrorExp.hs diff --git a/test/testdata/splice/TErrorExp.hs.expected b/plugins/hls-splice-plugin/test/testdata/TErrorExp.hs.expected similarity index 100% rename from test/testdata/splice/TErrorExp.hs.expected rename to plugins/hls-splice-plugin/test/testdata/TErrorExp.hs.expected diff --git a/test/testdata/splice/TErrorPat.hs b/plugins/hls-splice-plugin/test/testdata/TErrorPat.hs similarity index 100% rename from test/testdata/splice/TErrorPat.hs rename to plugins/hls-splice-plugin/test/testdata/TErrorPat.hs diff --git a/test/testdata/splice/TErrorPat.hs.expected b/plugins/hls-splice-plugin/test/testdata/TErrorPat.hs.expected similarity index 100% rename from test/testdata/splice/TErrorPat.hs.expected rename to plugins/hls-splice-plugin/test/testdata/TErrorPat.hs.expected diff --git a/test/testdata/splice/TQQDecl.hs b/plugins/hls-splice-plugin/test/testdata/TQQDecl.hs similarity index 100% rename from test/testdata/splice/TQQDecl.hs rename to plugins/hls-splice-plugin/test/testdata/TQQDecl.hs diff --git a/test/testdata/splice/TQQDecl.hs.expected b/plugins/hls-splice-plugin/test/testdata/TQQDecl.hs.expected similarity index 100% rename from test/testdata/splice/TQQDecl.hs.expected rename to plugins/hls-splice-plugin/test/testdata/TQQDecl.hs.expected diff --git a/test/testdata/splice/TQQExp.hs b/plugins/hls-splice-plugin/test/testdata/TQQExp.hs similarity index 100% rename from test/testdata/splice/TQQExp.hs rename to plugins/hls-splice-plugin/test/testdata/TQQExp.hs diff --git a/test/testdata/splice/TQQExp.hs.expected b/plugins/hls-splice-plugin/test/testdata/TQQExp.hs.expected similarity index 100% rename from test/testdata/splice/TQQExp.hs.expected rename to plugins/hls-splice-plugin/test/testdata/TQQExp.hs.expected diff --git a/test/testdata/splice/TQQExpError.hs b/plugins/hls-splice-plugin/test/testdata/TQQExpError.hs similarity index 100% rename from test/testdata/splice/TQQExpError.hs rename to plugins/hls-splice-plugin/test/testdata/TQQExpError.hs diff --git a/test/testdata/splice/TQQExpError.hs.expected b/plugins/hls-splice-plugin/test/testdata/TQQExpError.hs.expected similarity index 100% rename from test/testdata/splice/TQQExpError.hs.expected rename to plugins/hls-splice-plugin/test/testdata/TQQExpError.hs.expected diff --git a/test/testdata/splice/TQQPat.hs b/plugins/hls-splice-plugin/test/testdata/TQQPat.hs similarity index 100% rename from test/testdata/splice/TQQPat.hs rename to plugins/hls-splice-plugin/test/testdata/TQQPat.hs diff --git a/test/testdata/splice/TQQPat.hs.expected b/plugins/hls-splice-plugin/test/testdata/TQQPat.hs.expected similarity index 100% rename from test/testdata/splice/TQQPat.hs.expected rename to plugins/hls-splice-plugin/test/testdata/TQQPat.hs.expected diff --git a/test/testdata/splice/TQQPatError.hs b/plugins/hls-splice-plugin/test/testdata/TQQPatError.hs similarity index 100% rename from test/testdata/splice/TQQPatError.hs rename to plugins/hls-splice-plugin/test/testdata/TQQPatError.hs diff --git a/test/testdata/splice/TQQPatError.hs.expected b/plugins/hls-splice-plugin/test/testdata/TQQPatError.hs.expected similarity index 100% rename from test/testdata/splice/TQQPatError.hs.expected rename to plugins/hls-splice-plugin/test/testdata/TQQPatError.hs.expected diff --git a/test/testdata/splice/TQQType.hs b/plugins/hls-splice-plugin/test/testdata/TQQType.hs similarity index 100% rename from test/testdata/splice/TQQType.hs rename to plugins/hls-splice-plugin/test/testdata/TQQType.hs diff --git a/test/testdata/splice/TQQType.hs.expected b/plugins/hls-splice-plugin/test/testdata/TQQType.hs.expected similarity index 100% rename from test/testdata/splice/TQQType.hs.expected rename to plugins/hls-splice-plugin/test/testdata/TQQType.hs.expected diff --git a/test/testdata/splice/TQQTypeTypeError.hs b/plugins/hls-splice-plugin/test/testdata/TQQTypeTypeError.hs similarity index 100% rename from test/testdata/splice/TQQTypeTypeError.hs rename to plugins/hls-splice-plugin/test/testdata/TQQTypeTypeError.hs diff --git a/test/testdata/splice/TQQTypeTypeError.hs.expected b/plugins/hls-splice-plugin/test/testdata/TQQTypeTypeError.hs.expected similarity index 100% rename from test/testdata/splice/TQQTypeTypeError.hs.expected rename to plugins/hls-splice-plugin/test/testdata/TQQTypeTypeError.hs.expected diff --git a/test/testdata/splice/TSimpleDecl.hs b/plugins/hls-splice-plugin/test/testdata/TSimpleDecl.hs similarity index 100% rename from test/testdata/splice/TSimpleDecl.hs rename to plugins/hls-splice-plugin/test/testdata/TSimpleDecl.hs diff --git a/test/testdata/splice/TSimpleDecl.hs.expected b/plugins/hls-splice-plugin/test/testdata/TSimpleDecl.hs.expected similarity index 100% rename from test/testdata/splice/TSimpleDecl.hs.expected rename to plugins/hls-splice-plugin/test/testdata/TSimpleDecl.hs.expected diff --git a/test/testdata/splice/TSimpleExp.hs b/plugins/hls-splice-plugin/test/testdata/TSimpleExp.hs similarity index 100% rename from test/testdata/splice/TSimpleExp.hs rename to plugins/hls-splice-plugin/test/testdata/TSimpleExp.hs diff --git a/test/testdata/splice/TSimpleExp.hs.expected b/plugins/hls-splice-plugin/test/testdata/TSimpleExp.hs.expected similarity index 100% rename from test/testdata/splice/TSimpleExp.hs.expected rename to plugins/hls-splice-plugin/test/testdata/TSimpleExp.hs.expected diff --git a/test/testdata/splice/TSimplePat.hs b/plugins/hls-splice-plugin/test/testdata/TSimplePat.hs similarity index 100% rename from test/testdata/splice/TSimplePat.hs rename to plugins/hls-splice-plugin/test/testdata/TSimplePat.hs diff --git a/test/testdata/splice/TSimplePat.hs.expected b/plugins/hls-splice-plugin/test/testdata/TSimplePat.hs.expected similarity index 100% rename from test/testdata/splice/TSimplePat.hs.expected rename to plugins/hls-splice-plugin/test/testdata/TSimplePat.hs.expected diff --git a/test/testdata/splice/TSimpleType.hs b/plugins/hls-splice-plugin/test/testdata/TSimpleType.hs similarity index 100% rename from test/testdata/splice/TSimpleType.hs rename to plugins/hls-splice-plugin/test/testdata/TSimpleType.hs diff --git a/test/testdata/splice/TSimpleType.hs.expected b/plugins/hls-splice-plugin/test/testdata/TSimpleType.hs.expected similarity index 100% rename from test/testdata/splice/TSimpleType.hs.expected rename to plugins/hls-splice-plugin/test/testdata/TSimpleType.hs.expected diff --git a/test/testdata/splice/TTypeAppExp.hs b/plugins/hls-splice-plugin/test/testdata/TTypeAppExp.hs similarity index 100% rename from test/testdata/splice/TTypeAppExp.hs rename to plugins/hls-splice-plugin/test/testdata/TTypeAppExp.hs diff --git a/test/testdata/splice/TTypeAppExp.hs.expected b/plugins/hls-splice-plugin/test/testdata/TTypeAppExp.hs.expected similarity index 100% rename from test/testdata/splice/TTypeAppExp.hs.expected rename to plugins/hls-splice-plugin/test/testdata/TTypeAppExp.hs.expected diff --git a/test/testdata/splice/TTypeKindError.hs b/plugins/hls-splice-plugin/test/testdata/TTypeKindError.hs similarity index 100% rename from test/testdata/splice/TTypeKindError.hs rename to plugins/hls-splice-plugin/test/testdata/TTypeKindError.hs diff --git a/test/testdata/splice/TTypeKindError.hs.error b/plugins/hls-splice-plugin/test/testdata/TTypeKindError.hs.error similarity index 100% rename from test/testdata/splice/TTypeKindError.hs.error rename to plugins/hls-splice-plugin/test/testdata/TTypeKindError.hs.error diff --git a/test/testdata/splice/TTypeKindError.hs.expected b/plugins/hls-splice-plugin/test/testdata/TTypeKindError.hs.expected similarity index 100% rename from test/testdata/splice/TTypeKindError.hs.expected rename to plugins/hls-splice-plugin/test/testdata/TTypeKindError.hs.expected diff --git a/test/testdata/splice/TTypeTypeError.hs b/plugins/hls-splice-plugin/test/testdata/TTypeTypeError.hs similarity index 100% rename from test/testdata/splice/TTypeTypeError.hs rename to plugins/hls-splice-plugin/test/testdata/TTypeTypeError.hs diff --git a/test/testdata/splice/TTypeTypeError.hs.expected b/plugins/hls-splice-plugin/test/testdata/TTypeTypeError.hs.expected similarity index 100% rename from test/testdata/splice/TTypeTypeError.hs.expected rename to plugins/hls-splice-plugin/test/testdata/TTypeTypeError.hs.expected diff --git a/test/testdata/splice/hie.yaml b/plugins/hls-splice-plugin/test/testdata/hie.yaml similarity index 100% rename from test/testdata/splice/hie.yaml rename to plugins/hls-splice-plugin/test/testdata/hie.yaml diff --git a/plugins/hls-stylish-haskell-plugin/hls-stylish-haskell-plugin.cabal b/plugins/hls-stylish-haskell-plugin/hls-stylish-haskell-plugin.cabal index ceeffc17bc..051fbe40bf 100644 --- a/plugins/hls-stylish-haskell-plugin/hls-stylish-haskell-plugin.cabal +++ b/plugins/hls-stylish-haskell-plugin/hls-stylish-haskell-plugin.cabal @@ -53,6 +53,5 @@ test-suite tests build-depends: , base , bytestring - , hls-stylish-haskell-plugin , hls-test-utils , text diff --git a/plugins/hls-tactics-plugin/hls-tactics-plugin.cabal b/plugins/hls-tactics-plugin/hls-tactics-plugin.cabal index ff9a28ce47..357883a479 100644 --- a/plugins/hls-tactics-plugin/hls-tactics-plugin.cabal +++ b/plugins/hls-tactics-plugin/hls-tactics-plugin.cabal @@ -1,4 +1,4 @@ -cabal-version: 2.2 +cabal-version: 2.4 category: Development name: hls-tactics-plugin version: 1.0.0.0 @@ -17,7 +17,7 @@ extra-source-files: test/golden/*.cabal test/golden/*.yaml test/golden/*.hs - test/golden/*.hs.expected + test/golden/*.expected flag pedantic diff --git a/test/functional/Command.hs b/test/functional/Command.hs index 5fb20c43c1..871a2d82ba 100644 --- a/test/functional/Command.hs +++ b/test/functional/Command.hs @@ -7,6 +7,7 @@ import qualified Data.Text as T import Language.LSP.Types as LSP import Language.LSP.Types.Lens as LSP import Test.Hls +import Test.Hls.Command tests :: TestTree tests = testGroup "commands" [ diff --git a/test/functional/Completion.hs b/test/functional/Completion.hs index 92b7883bf5..2e665ce995 100644 --- a/test/functional/Completion.hs +++ b/test/functional/Completion.hs @@ -8,6 +8,7 @@ import qualified Data.Text as T import Ide.Plugin.Config (maxCompletions) import Language.LSP.Types.Lens hiding (applyEdit) import Test.Hls +import Test.Hls.Command tests :: TestTree tests = testGroup "completions" [ diff --git a/test/functional/Config.hs b/test/functional/Config.hs index d5a4c17cb5..b6623ed9ea 100644 --- a/test/functional/Config.hs +++ b/test/functional/Config.hs @@ -12,6 +12,7 @@ import Language.LSP.Test as Test import qualified Language.LSP.Types.Lens as L import System.FilePath (()) import Test.Hls +import Test.Hls.Command {-# ANN module ("HLint: ignore Reduce duplication"::String) #-} diff --git a/test/functional/Deferred.hs b/test/functional/Deferred.hs index ace17a4cbe..02239701e9 100644 --- a/test/functional/Deferred.hs +++ b/test/functional/Deferred.hs @@ -9,6 +9,7 @@ import Control.Lens hiding (List) import Language.LSP.Types.Lens hiding (id, message) -- import qualified Language.LSP.Types.Lens as LSP import Test.Hls +import Test.Hls.Command tests :: TestTree diff --git a/test/functional/Definition.hs b/test/functional/Definition.hs index 67beba9e56..85ed8b876d 100644 --- a/test/functional/Definition.hs +++ b/test/functional/Definition.hs @@ -4,6 +4,7 @@ import Control.Lens import Language.LSP.Types.Lens import System.Directory import Test.Hls +import Test.Hls.Command tests :: TestTree tests = testGroup "definitions" [ diff --git a/test/functional/Diagnostic.hs b/test/functional/Diagnostic.hs index 3966de9545..bfe304d99e 100644 --- a/test/functional/Diagnostic.hs +++ b/test/functional/Diagnostic.hs @@ -8,6 +8,7 @@ import qualified Data.Default import Ide.Plugin.Config import qualified Language.LSP.Types.Lens as LSP import Test.Hls +import Test.Hls.Command -- --------------------------------------------------------------------- diff --git a/test/functional/Format.hs b/test/functional/Format.hs index 4b2c201a1e..339e849e6a 100644 --- a/test/functional/Format.hs +++ b/test/functional/Format.hs @@ -12,6 +12,7 @@ import Language.LSP.Test import Language.LSP.Types import qualified Language.LSP.Types.Lens as LSP import Test.Hls +import Test.Hls.Command tests :: TestTree tests = testGroup "format document" [ diff --git a/test/functional/FunctionalCodeAction.hs b/test/functional/FunctionalCodeAction.hs index 358f9d9768..00ccc42832 100644 --- a/test/functional/FunctionalCodeAction.hs +++ b/test/functional/FunctionalCodeAction.hs @@ -22,6 +22,7 @@ import Test.Hspec.Expectations import System.FilePath (()) import System.IO.Extra (withTempDir) +import Test.Hls.Command {-# ANN module ("HLint: ignore Reduce duplication"::String) #-} diff --git a/test/functional/FunctionalLiquid.hs b/test/functional/FunctionalLiquid.hs index 99a36eb607..77a553f7ad 100644 --- a/test/functional/FunctionalLiquid.hs +++ b/test/functional/FunctionalLiquid.hs @@ -7,6 +7,8 @@ import Data.Aeson import Ide.Plugin.Config import Language.LSP.Types.Lens as LSP hiding (contents) import Test.Hls +import Test.Hls.Command + -- --------------------------------------------------------------------- tests :: TestTree diff --git a/test/functional/HieBios.hs b/test/functional/HieBios.hs index 11f5163cd4..1ab9f2837e 100644 --- a/test/functional/HieBios.hs +++ b/test/functional/HieBios.hs @@ -7,6 +7,7 @@ import qualified Data.Text as T import qualified Language.LSP.Types.Lens as L import System.FilePath (()) import Test.Hls +import Test.Hls.Command tests :: TestTree diff --git a/test/functional/Highlight.hs b/test/functional/Highlight.hs index ec518d956e..fcc8e8ea04 100644 --- a/test/functional/Highlight.hs +++ b/test/functional/Highlight.hs @@ -2,6 +2,7 @@ module Highlight (tests) where import Test.Hls +import Test.Hls.Command tests :: TestTree tests = testGroup "highlight" [ diff --git a/test/functional/Main.hs b/test/functional/Main.hs index 2ae16e5f37..660eee674d 100644 --- a/test/functional/Main.hs +++ b/test/functional/Main.hs @@ -1,6 +1,5 @@ module Main where -import Class import Command import Completion import Config @@ -11,14 +10,12 @@ import Format import FunctionalBadProject import FunctionalCodeAction import FunctionalLiquid -import HaddockComments import HieBios import Highlight import ModuleName import Progress import Reference import Rename -import Splice import Symbol import Test.Hls import TypeDefinition @@ -27,8 +24,7 @@ main :: IO () main = defaultTestRunner $ testGroup "haskell-language-server" - [ Class.tests - , Command.tests + [ Command.tests , Completion.tests , Config.tests , Deferred.tests @@ -46,6 +42,4 @@ main = defaultTestRunner , Rename.tests , Symbol.tests , TypeDefinition.tests - , Splice.tests - , HaddockComments.tests ] diff --git a/test/functional/ModuleName.hs b/test/functional/ModuleName.hs index 077d4cb35b..7c5b6130ba 100644 --- a/test/functional/ModuleName.hs +++ b/test/functional/ModuleName.hs @@ -7,9 +7,10 @@ module ModuleName ) where -import qualified Data.Text.IO as T -import System.FilePath ((<.>), ()) +import qualified Data.Text.IO as T +import System.FilePath ((<.>), ()) import Test.Hls +import Test.Hls.Command tests :: TestTree tests = testGroup diff --git a/test/functional/Progress.hs b/test/functional/Progress.hs index 3e5c6d186f..58e0e8bbe8 100644 --- a/test/functional/Progress.hs +++ b/test/functional/Progress.hs @@ -18,6 +18,7 @@ import Language.LSP.Types.Capabilities import qualified Language.LSP.Types.Lens as L import System.FilePath (()) import Test.Hls +import Test.Hls.Command tests :: TestTree tests = diff --git a/test/functional/Reference.hs b/test/functional/Reference.hs index 994e1b6082..e3304fbec1 100644 --- a/test/functional/Reference.hs +++ b/test/functional/Reference.hs @@ -5,6 +5,7 @@ import Data.Coerce import Data.List import Language.LSP.Types.Lens import Test.Hls +import Test.Hls.Command tests :: TestTree tests = testGroup "references" [ diff --git a/test/functional/Rename.hs b/test/functional/Rename.hs index aa6272e2a4..08de8a63d9 100644 --- a/test/functional/Rename.hs +++ b/test/functional/Rename.hs @@ -2,6 +2,7 @@ module Rename (tests) where import Test.Hls +import Test.Hls.Command tests :: TestTree tests = testGroup "rename" [ diff --git a/test/functional/Symbol.hs b/test/functional/Symbol.hs index 78fae0bf4b..965d30d4c1 100644 --- a/test/functional/Symbol.hs +++ b/test/functional/Symbol.hs @@ -7,6 +7,7 @@ import Language.LSP.Test as Test import Language.LSP.Types.Capabilities import qualified Language.LSP.Types.Lens as L import Test.Hls +import Test.Hls.Command tests :: TestTree tests = testGroup "document symbols" [ diff --git a/test/functional/TypeDefinition.hs b/test/functional/TypeDefinition.hs index b56198c62d..1bba39440b 100644 --- a/test/functional/TypeDefinition.hs +++ b/test/functional/TypeDefinition.hs @@ -3,6 +3,7 @@ module TypeDefinition (tests) where import Data.Tuple.Extra (first3) import System.FilePath (()) import Test.Hls +import Test.Hls.Command tests :: TestTree tests = testGroup "type definitions" [ diff --git a/test/testdata/splice/.gitignore b/test/testdata/splice/.gitignore deleted file mode 100644 index 229336d2f3..0000000000 --- a/test/testdata/splice/.gitignore +++ /dev/null @@ -1 +0,0 @@ -!hie.yaml diff --git a/test/utils/Test/Hls/Command.hs b/test/utils/Test/Hls/Command.hs new file mode 100644 index 0000000000..656aca1beb --- /dev/null +++ b/test/utils/Test/Hls/Command.hs @@ -0,0 +1,32 @@ +module Test.Hls.Command + ( hlsCommand, + hlsCommandExamplePlugin, + hlsCommandVomit, + logFilePath, + ) +where + +import Data.Maybe (fromMaybe) +import System.Environment (lookupEnv) +import System.IO.Unsafe (unsafePerformIO) +import Test.Hls + +logFilePath :: String +logFilePath = "hls-" ++ show ghcVersion ++ ".log" + +-- | The command to execute the version of hls for the current compiler. +-- +-- Both @stack test@ and @cabal new-test@ setup the environment so @hls@ is +-- on PATH. Cabal seems to respond to @build-tool-depends@ specifically while +-- stack just puts all project executables on PATH. +hlsCommand :: String +{-# NOINLINE hlsCommand #-} +hlsCommand = unsafePerformIO $ do + testExe <- fromMaybe "haskell-language-server" <$> lookupEnv "HLS_TEST_EXE" + pure $ testExe ++ " --lsp -d -j2 -l test-logs/" ++ logFilePath + +hlsCommandVomit :: String +hlsCommandVomit = hlsCommand ++ " --vomit" + +hlsCommandExamplePlugin :: String +hlsCommandExamplePlugin = hlsCommand ++ " --example"