From 61fd5c464842448dfebe91d3e01de425eacf07b7 Mon Sep 17 00:00:00 2001 From: soulomoon Date: Mon, 13 May 2024 10:18:51 +0800 Subject: [PATCH] [Migrate diagnosticTests] part of #4173 Migrate ghcide tests to hls test utils (#4207) * [x] migrate diagnosticTests, figure out how to pass `--test-no-kick`. * [x] migrate openCloseTests * [x] Lift a few functions from ghcide-test-utils to hls-test-utils * [x] fixed `deeply nested cyclic module dependency` * [x] modify `runSessionWithServer'` and ghcIde arguments to admit additional a switch for `no-kick`. --------- Co-authored-by: fendor --- ghcide/exe/Main.hs | 5 - ghcide/src/Development/IDE/Main.hs | 12 +- ghcide/test/exe/ClientSettingsTests.hs | 1 + ghcide/test/exe/CodeLensTests.hs | 1 + ghcide/test/exe/CompletionTests.hs | 4 +- ghcide/test/exe/Config.hs | 50 ++++++-- ghcide/test/exe/DiagnosticTests.hs | 116 +++++++++-------- ghcide/test/exe/ExceptionTests.hs | 1 + ghcide/test/exe/InitializeResponseTests.hs | 2 +- ghcide/test/exe/OpenCloseTest.hs | 6 +- ghcide/test/exe/THTests.hs | 2 + ghcide/test/exe/TestUtils.hs | 34 +---- ghcide/test/exe/UnitTests.hs | 1 + hls-test-utils/src/Test/Hls.hs | 118 ++++++++++-------- plugins/hls-refactor-plugin/test/Main.hs | 24 ++-- .../test/SemanticTokensTest.hs | 4 +- test/functional/Config.hs | 3 +- 17 files changed, 198 insertions(+), 186 deletions(-) diff --git a/ghcide/exe/Main.hs b/ghcide/exe/Main.hs index 823d6faba6..3344648150 100644 --- a/ghcide/exe/Main.hs +++ b/ghcide/exe/Main.hs @@ -124,12 +124,7 @@ main = withTelemetryRecorder $ \telemetryRecorder -> do , IDEMain.argsHlsPlugins = IDEMain.argsHlsPlugins arguments <> pluginDescToIdePlugins [lspRecorderPlugin] , IDEMain.argsRules = do - -- install the main and ghcide-plugin rules mainRule (cmapWithPrio LogRules recorder) def - -- install the kick action, which triggers a typecheck on every - -- Shake database restart, i.e. on every user edit. - unless argsDisableKick $ - action kick , IDEMain.argsThreads = case argsThreads of 0 -> Nothing ; i -> Just (fromIntegral i) diff --git a/ghcide/src/Development/IDE/Main.hs b/ghcide/src/Development/IDE/Main.hs index 04d4b4cb42..b4aa72f5fa 100644 --- a/ghcide/src/Development/IDE/Main.hs +++ b/ghcide/src/Development/IDE/Main.hs @@ -223,13 +223,14 @@ data Arguments = Arguments , argsHandleOut :: IO Handle , argsThreads :: Maybe Natural , argsMonitoring :: IO Monitoring + , argsDisableKick :: Bool -- ^ flag to disable kick used for testing } defaultArguments :: Recorder (WithPriority Log) -> IdePlugins IdeState -> Arguments defaultArguments recorder plugins = Arguments { argsProjectRoot = Nothing , argCommand = LSP - , argsRules = mainRule (cmapWithPrio LogRules recorder) def >> action kick + , argsRules = mainRule (cmapWithPrio LogRules recorder) def , argsGhcidePlugin = mempty , argsHlsPlugins = pluginDescToIdePlugins (GhcIde.descriptors (cmapWithPrio LogGhcIde recorder)) <> plugins , argsSessionLoadingOptions = def @@ -258,6 +259,7 @@ defaultArguments recorder plugins = Arguments putStr " " >> hFlush stdout return newStdout , argsMonitoring = OpenTelemetry.monitoring + , argsDisableKick = False } @@ -293,7 +295,13 @@ defaultMain recorder Arguments{..} = withHeapStats (cmapWithPrio LogHeapStats re plugins = hlsPlugin <> argsGhcidePlugin options = argsLspOptions { LSP.optExecuteCommandCommands = LSP.optExecuteCommandCommands argsLspOptions <> Just hlsCommands } argsParseConfig = getConfigFromNotification argsHlsPlugins - rules = argsRules >> pluginRules plugins + rules = do + argsRules + unless argsDisableKick $ action kick + pluginRules plugins + -- install the main and ghcide-plugin rules + -- install the kick action, which triggers a typecheck on every + -- Shake database restart, i.e. on every user edit. debouncer <- argsDebouncer inH <- argsHandleIn diff --git a/ghcide/test/exe/ClientSettingsTests.hs b/ghcide/test/exe/ClientSettingsTests.hs index 6801e9fe8a..6d964d3542 100644 --- a/ghcide/test/exe/ClientSettingsTests.hs +++ b/ghcide/test/exe/ClientSettingsTests.hs @@ -14,6 +14,7 @@ import Language.LSP.Protocol.Types hiding SemanticTokensEdit (..), mkRange) import Language.LSP.Test +import Test.Hls (waitForProgressDone) import Test.Tasty import TestUtils diff --git a/ghcide/test/exe/CodeLensTests.hs b/ghcide/test/exe/CodeLensTests.hs index e6cb6a4062..6bebeda002 100644 --- a/ghcide/test/exe/CodeLensTests.hs +++ b/ghcide/test/exe/CodeLensTests.hs @@ -18,6 +18,7 @@ import Language.LSP.Protocol.Types hiding SemanticTokensEdit (..), mkRange) import Language.LSP.Test +import Test.Hls (waitForProgressDone) import Test.Tasty import Test.Tasty.HUnit import TestUtils diff --git a/ghcide/test/exe/CompletionTests.hs b/ghcide/test/exe/CompletionTests.hs index 856598bf60..590f0b707a 100644 --- a/ghcide/test/exe/CompletionTests.hs +++ b/ghcide/test/exe/CompletionTests.hs @@ -49,10 +49,10 @@ tests ] testSessionEmpty :: TestName -> Session () -> TestTree -testSessionEmpty name = testCase name . runWithDummyPlugin (mkIdeTestFs [FS.directCradle ["A.hs"]]) +testSessionEmpty name = testWithDummyPlugin name (mkIdeTestFs [FS.directCradle ["A.hs"]]) testSessionEmptyWithCradle :: TestName -> T.Text -> Session () -> TestTree -testSessionEmptyWithCradle name cradle = testCase name . runWithDummyPlugin (mkIdeTestFs [file "hie.yaml" (text cradle)]) +testSessionEmptyWithCradle name cradle = testWithDummyPlugin name (mkIdeTestFs [file "hie.yaml" (text cradle)]) testSessionSingleFile :: TestName -> FilePath -> T.Text -> Session () -> TestTree testSessionSingleFile testName fp txt session = diff --git a/ghcide/test/exe/Config.hs b/ghcide/test/exe/Config.hs index f8232de343..540e0b2451 100644 --- a/ghcide/test/exe/Config.hs +++ b/ghcide/test/exe/Config.hs @@ -1,11 +1,37 @@ {-# LANGUAGE PatternSynonyms #-} -module Config where - +module Config( + -- * basic config for ghcIde testing + mkIdeTestFs + , dummyPlugin + + -- * runners for testing with dummy plugin + , runWithDummyPlugin + , testWithDummyPlugin + , testWithDummyPluginEmpty + , testWithDummyPlugin' + , testWithDummyPluginEmpty' + , testWithDummyPluginAndCap' + , runWithExtraFiles + , testWithExtraFiles + + -- * utilities for testing definition and hover + , Expect(..) + , pattern R + , mkR + , checkDefs + , mkL + , lspTestCaps + , lspTestCapsNoFileWatches + ) where + +import Control.Lens.Setter ((.~)) import Data.Foldable (traverse_) +import Data.Function ((&)) import qualified Data.Text as T import Development.IDE.Test (canonicalizeUri) import Ide.Types (defaultPluginDescriptor) +import qualified Language.LSP.Protocol.Lens as L import Language.LSP.Protocol.Types (Null (..)) import System.FilePath (()) import Test.Hls @@ -28,22 +54,18 @@ runWithDummyPlugin = runSessionWithServerInTmpDir def dummyPlugin runWithDummyPlugin' :: FS.VirtualFileTree -> (FileSystem -> Session a) -> IO a runWithDummyPlugin' = runSessionWithServerInTmpDirCont' def dummyPlugin -runWithDummyPluginAndCap :: ClientCapabilities -> Session () -> IO () -runWithDummyPluginAndCap cap = runSessionWithServerAndCapsInTmpDir def dummyPlugin cap (mkIdeTestFs []) +runWithDummyPluginAndCap' :: ClientCapabilities -> (FileSystem -> Session ()) -> IO () +runWithDummyPluginAndCap' cap = runSessionWithServerAndCapsInTmpDirCont def dummyPlugin cap (mkIdeTestFs []) -testWithDummyPluginAndCap :: String -> ClientCapabilities -> Session () -> TestTree -testWithDummyPluginAndCap caseName cap = testCase caseName . runWithDummyPluginAndCap cap +testWithDummyPluginAndCap' :: String -> ClientCapabilities -> (FileSystem -> Session ()) -> TestTree +testWithDummyPluginAndCap' caseName cap = testCase caseName . runWithDummyPluginAndCap' cap --- testSessionWithCorePlugin ::(TestRunner cont ()) => TestName -> FS.VirtualFileTree -> cont -> TestTree testWithDummyPlugin :: String -> FS.VirtualFileTree -> Session () -> TestTree -testWithDummyPlugin caseName vfs = testCase caseName . runWithDummyPlugin vfs +testWithDummyPlugin caseName vfs = testWithDummyPlugin' caseName vfs . const testWithDummyPlugin' :: String -> FS.VirtualFileTree -> (FileSystem -> Session ()) -> TestTree testWithDummyPlugin' caseName vfs = testCase caseName . runWithDummyPlugin' vfs -runWithDummyPluginEmpty :: Session a -> IO a -runWithDummyPluginEmpty = runWithDummyPlugin $ mkIdeTestFs [] - testWithDummyPluginEmpty :: String -> Session () -> TestTree testWithDummyPluginEmpty caseName = testWithDummyPlugin caseName $ mkIdeTestFs [] @@ -114,3 +136,9 @@ defToLocation (InL (Definition (InL l))) = [l] defToLocation (InL (Definition (InR ls))) = ls defToLocation (InR (InL defLink)) = (\(DefinitionLink LocationLink{_targetUri,_targetRange}) -> Location _targetUri _targetRange) <$> defLink defToLocation (InR (InR Null)) = [] + +lspTestCaps :: ClientCapabilities +lspTestCaps = fullCaps { _window = Just $ WindowClientCapabilities (Just True) Nothing Nothing } + +lspTestCapsNoFileWatches :: ClientCapabilities +lspTestCapsNoFileWatches = lspTestCaps & L.workspace . traverse . L.didChangeWatchedFiles .~ Nothing diff --git a/ghcide/test/exe/DiagnosticTests.hs b/ghcide/test/exe/DiagnosticTests.hs index fe123c5c1d..c0678aaf18 100644 --- a/ghcide/test/exe/DiagnosticTests.hs +++ b/ghcide/test/exe/DiagnosticTests.hs @@ -30,17 +30,24 @@ import System.Directory import System.FilePath import System.IO.Extra hiding (withTempDir) +import Config import Control.Lens ((^.)) import Control.Monad.Extra (whenJust) +import Data.Default (def) import Development.IDE.Plugin.Test (WaitForIdeRuleResult (..)) import System.Time.Extra +import Test.Hls (runSessionWithServer', + runSessionWithServerInTmpDirCont, + waitForProgressBegin, + waitForTypecheck) +import Test.Hls.FileSystem (directCradle, file, text, + toAbsFp) import Test.Tasty import Test.Tasty.HUnit -import TestUtils tests :: TestTree tests = testGroup "diagnostics" - [ testSessionWait "fix syntax error" $ do + [ testWithDummyPluginEmpty "fix syntax error" $ do let content = T.unlines [ "module Testing wher" ] doc <- createDoc "Testing.hs" "haskell" content expectDiagnostics [("Testing.hs", [(DiagnosticSeverity_Error, (0, 15), "parse error")])] @@ -51,7 +58,7 @@ tests = testGroup "diagnostics" } changeDoc doc [change] expectDiagnostics [("Testing.hs", [])] - , testSessionWait "introduce syntax error" $ do + , testWithDummyPluginEmpty "introduce syntax error" $ do let content = T.unlines [ "module Testing where" ] doc <- createDoc "Testing.hs" "haskell" content void $ skipManyTill anyMessage (message SMethod_WindowWorkDoneProgressCreate) @@ -63,7 +70,7 @@ tests = testGroup "diagnostics" } changeDoc doc [change] expectDiagnostics [("Testing.hs", [(DiagnosticSeverity_Error, (0, 15), "parse error")])] - , testSessionWait "update syntax error" $ do + , testWithDummyPluginEmpty "update syntax error" $ do let content = T.unlines [ "module Testing(missing) where" ] doc <- createDoc "Testing.hs" "haskell" content expectDiagnostics [("Testing.hs", [(DiagnosticSeverity_Error, (0, 15), "Not in scope: 'missing'")])] @@ -74,7 +81,7 @@ tests = testGroup "diagnostics" } changeDoc doc [change] expectDiagnostics [("Testing.hs", [(DiagnosticSeverity_Error, (0, 15), "Not in scope: 'lissing'")])] - , testSessionWait "variable not in scope" $ do + , testWithDummyPluginEmpty "variable not in scope" $ do let content = T.unlines [ "module Testing where" , "foo :: Int -> Int -> Int" @@ -90,7 +97,7 @@ tests = testGroup "diagnostics" ] ) ] - , testSessionWait "type error" $ do + , testWithDummyPluginEmpty "type error" $ do let content = T.unlines [ "module Testing where" , "foo :: Int -> String -> Int" @@ -102,7 +109,7 @@ tests = testGroup "diagnostics" , [(DiagnosticSeverity_Error, (2, 14), "Couldn't match type '[Char]' with 'Int'")] ) ] - , testSessionWait "typed hole" $ do + , testWithDummyPluginEmpty "typed hole" $ do let content = T.unlines [ "module Testing where" , "foo :: Int -> String" @@ -129,7 +136,7 @@ tests = testGroup "diagnostics" expectedDs aMessage = [ ("A.hs", [(DiagnosticSeverity_Error, (2,4), aMessage)]) , ("B.hs", [(DiagnosticSeverity_Error, (3,4), bMessage)])] - deferralTest title binding msg = testSessionWait title $ do + deferralTest title binding msg = testWithDummyPluginEmpty title $ do _ <- createDoc "A.hs" "haskell" $ sourceA binding _ <- createDoc "B.hs" "haskell" sourceB expectDiagnostics $ expectedDs msg @@ -139,7 +146,7 @@ tests = testGroup "diagnostics" , deferralTest "out of scope var" "unbound" "Variable not in scope" ] - , testSessionWait "remove required module" $ do + , testWithDummyPluginEmpty "remove required module" $ do let contentA = T.unlines [ "module ModuleA where" ] docA <- createDoc "ModuleA.hs" "haskell" contentA let contentB = T.unlines @@ -154,7 +161,7 @@ tests = testGroup "diagnostics" } changeDoc docA [change] expectDiagnostics [("ModuleB.hs", [(DiagnosticSeverity_Error, (1, 0), "Could not find module")])] - , testSessionWait "add missing module" $ do + , testWithDummyPluginEmpty "add missing module" $ do let contentB = T.unlines [ "module ModuleB where" , "import ModuleA ()" @@ -164,22 +171,21 @@ tests = testGroup "diagnostics" let contentA = T.unlines [ "module ModuleA where" ] _ <- createDoc "ModuleA.hs" "haskell" contentA expectDiagnostics [("ModuleB.hs", [])] - , testCase "add missing module (non workspace)" $ + , testWithDummyPluginAndCap' "add missing module (non workspace)" lspTestCapsNoFileWatches $ \tmpDir -> do -- By default lsp-test sends FileWatched notifications for all files, which we don't want -- as non workspace modules will not be watched by the LSP server. -- To work around this, we tell lsp-test that our client doesn't have the -- FileWatched capability, which is enough to disable the notifications - withTempDir $ \tmpDir -> runInDir'' lspTestCapsNoFileWatches tmpDir "." "." [] $ do let contentB = T.unlines [ "module ModuleB where" , "import ModuleA ()" ] - _ <- createDoc (tmpDir "ModuleB.hs") "haskell" contentB - expectDiagnostics [(tmpDir "ModuleB.hs", [(DiagnosticSeverity_Error, (1, 7), "Could not find module")])] + _ <- createDoc (tmpDir `toAbsFp` "ModuleB.hs") "haskell" contentB + expectDiagnostics [(tmpDir `toAbsFp` "ModuleB.hs", [(DiagnosticSeverity_Error, (1, 7), "Could not find module")])] let contentA = T.unlines [ "module ModuleA where" ] - _ <- createDoc (tmpDir "ModuleA.hs") "haskell" contentA - expectDiagnostics [(tmpDir "ModuleB.hs", [])] - , testSessionWait "cyclic module dependency" $ do + _ <- createDoc (tmpDir `toAbsFp` "ModuleA.hs") "haskell" contentA + expectDiagnostics [(tmpDir `toAbsFp` "ModuleB.hs", [])] + , testWithDummyPluginEmpty "cyclic module dependency" $ do let contentA = T.unlines [ "module ModuleA where" , "import ModuleB" @@ -198,28 +204,24 @@ tests = testGroup "diagnostics" , [(DiagnosticSeverity_Error, (1, 7), "Cyclic module dependency between ModuleA, ModuleB")] ) ] - , testSession' "deeply nested cyclic module dependency" $ \path -> do - let contentA = unlines - [ "module ModuleA where" , "import ModuleB" ] - let contentB = unlines - [ "module ModuleB where" , "import ModuleA" ] - let contentC = unlines - [ "module ModuleC where" , "import ModuleB" ] - let contentD = T.unlines - [ "module ModuleD where" , "import ModuleC" ] - cradle = - "cradle: {direct: {arguments: [ModuleA, ModuleB, ModuleC, ModuleD]}}" - liftIO $ writeFile (path "ModuleA.hs") contentA - liftIO $ writeFile (path "ModuleB.hs") contentB - liftIO $ writeFile (path "ModuleC.hs") contentC - liftIO $ writeFile (path "hie.yaml") cradle + , let contentA = T.unlines [ "module ModuleA where" , "import ModuleB" ] + contentB = T.unlines [ "module ModuleB where" , "import ModuleA" ] + contentC = T.unlines [ "module ModuleC where" , "import ModuleB" ] + contentD = T.unlines [ "module ModuleD where" , "import ModuleC" ] + cradle = directCradle ["ModuleA", "ModuleB", "ModuleC", "ModuleD"] + in testWithDummyPlugin "deeply nested cyclic module dependency" + (mkIdeTestFs [ + file "ModuleA.hs" (text contentA) + ,file "ModuleB.hs" (text contentB) + ,file "ModuleC.hs" (text contentC) + ,cradle + ]) $ do _ <- createDoc "ModuleD.hs" "haskell" contentD expectDiagnostics - [ ( "ModuleB.hs" - , [(DiagnosticSeverity_Error, (1, 7), "Cyclic module dependency between ModuleA, ModuleB")] - ) + [ ( "ModuleB.hs" , [(DiagnosticSeverity_Error, (1, 7), "Cyclic module dependency between ModuleA, ModuleB")]) + , ( "ModuleA.hs" , [(DiagnosticSeverity_Error, (1, 7), "Cyclic module dependency between ModuleA, ModuleB")]) ] - , testSessionWait "cyclic module dependency with hs-boot" $ do + , testWithDummyPluginEmpty "cyclic module dependency with hs-boot" $ do let contentA = T.unlines [ "module ModuleA where" , "import {-# SOURCE #-} ModuleB" @@ -238,11 +240,9 @@ tests = testGroup "diagnostics" _ <- createDoc "ModuleB.hs" "haskell" contentB _ <- createDoc "ModuleB.hs-boot" "haskell" contentBboot expectDiagnostics [("ModuleB.hs", [(DiagnosticSeverity_Warning, (3,0), "Top-level binding")])] - , testSession' "bidirectional module dependency with hs-boot" $ \path -> do - let cradle = unlines - [ "cradle:" - , " direct: {arguments: [ModuleA, ModuleB]}" - ] + , testWithDummyPlugin "bidirectional module dependency with hs-boot" + (mkIdeTestFs [directCradle ["ModuleA", "ModuleB"]]) + $ do let contentA = T.unlines [ "module ModuleA where" , "import {-# SOURCE #-} ModuleB" @@ -260,13 +260,12 @@ tests = testGroup "diagnostics" let contentAboot = T.unlines [ "module ModuleA where" ] - liftIO $ writeFile (path "hie.yaml") cradle _ <- createDoc "ModuleA.hs" "haskell" contentA _ <- createDoc "ModuleA.hs-boot" "haskell" contentAboot _ <- createDoc "ModuleB.hs" "haskell" contentB _ <- createDoc "ModuleB.hs-boot" "haskell" contentBboot expectDiagnostics [("ModuleB.hs", [(DiagnosticSeverity_Warning, (3,0), "Top-level binding")])] - , testSessionWait "correct reference used with hs-boot" $ do + , testWithDummyPluginEmpty "correct reference used with hs-boot" $ do let contentB = T.unlines [ "module ModuleB where" , "import {-# SOURCE #-} ModuleA()" @@ -292,7 +291,7 @@ tests = testGroup "diagnostics" _ <- createDoc "ModuleA.hs-boot" "haskell" contentAboot _ <- createDoc "ModuleC.hs" "haskell" contentC expectDiagnostics [("ModuleC.hs", [(DiagnosticSeverity_Warning, (3,0), "Top-level binding")])] - , testSessionWait "redundant import" $ do + , testWithDummyPluginEmpty "redundant import" $ do let contentA = T.unlines ["module ModuleA where"] let contentB = T.unlines [ "{-# OPTIONS_GHC -Wunused-imports #-}" @@ -306,7 +305,7 @@ tests = testGroup "diagnostics" , [(DiagnosticSeverity_Warning, (2, 0), "The import of 'ModuleA' is redundant", Just DiagnosticTag_Unnecessary)] ) ] - , testSessionWait "redundant import even without warning" $ do + , testWithDummyPluginEmpty "redundant import even without warning" $ do let contentA = T.unlines ["module ModuleA where"] let contentB = T.unlines [ "{-# OPTIONS_GHC -Wno-unused-imports -Wmissing-signatures #-}" @@ -318,7 +317,7 @@ tests = testGroup "diagnostics" _ <- createDoc "ModuleA.hs" "haskell" contentA _ <- createDoc "ModuleB.hs" "haskell" contentB expectDiagnostics [("ModuleB.hs", [(DiagnosticSeverity_Warning, (3,0), "Top-level binding")])] - , testSessionWait "package imports" $ do + , testWithDummyPluginEmpty "package imports" $ do let thisDataListContent = T.unlines [ "module Data.List where" , "x :: Integer" @@ -356,7 +355,7 @@ tests = testGroup "diagnostics" ] ) ] - , testSessionWait "unqualified warnings" $ do + , testWithDummyPluginEmpty "unqualified warnings" $ do let fooContent = T.unlines [ "{-# OPTIONS_GHC -Wredundant-constraints #-}" , "module Foo where" @@ -374,7 +373,7 @@ tests = testGroup "diagnostics" ] ) ] - , testSessionWait "lower-case drive" $ do + , testWithDummyPluginEmpty "lower-case drive" $ do let aContent = T.unlines [ "module A.A where" , "import A.B ()" @@ -407,7 +406,7 @@ tests = testGroup "diagnostics" liftIO $ unless ("redundant" `T.isInfixOf` msg) $ assertFailure ("Expected redundant import but got " <> T.unpack msg) closeDoc a - , testSessionWait "strip file path" $ do + , testWithDummyPluginEmpty "strip file path" $ do let name = "Testing" content = T.unlines @@ -426,9 +425,9 @@ tests = testGroup "diagnostics" Lens.filtered (T.isInfixOf ("/" <> name <> ".hs:")) failure msg = liftIO $ assertFailure $ "Expected file path to be stripped but got " <> T.unpack msg Lens.mapMOf_ offenders failure notification - , testSession' "-Werror in cradle is ignored" $ \sessionDir -> do - liftIO $ writeFile (sessionDir "hie.yaml") - "cradle: {direct: {arguments: [\"-Wall\", \"-Werror\"]}}" + , testWithDummyPlugin "-Werror in cradle is ignored" + (mkIdeTestFs [directCradle ["-Wall", "-Werror"]]) + $ do let fooContent = T.unlines [ "module Foo where" , "foo = ()" @@ -440,7 +439,7 @@ tests = testGroup "diagnostics" ] ) ] - , testSessionWait "-Werror in pragma is ignored" $ do + , testWithDummyPluginEmpty "-Werror in pragma is ignored" $ do let fooContent = T.unlines [ "{-# OPTIONS_GHC -Wall -Werror #-}" , "module Foo() where" @@ -455,9 +454,9 @@ tests = testGroup "diagnostics" ) ] , testCase "typecheck-all-parents-of-interest" $ runWithExtraFiles "recomp" $ \dir -> do - let bPath = dir "B.hs" - pPath = dir "P.hs" - aPath = dir "A.hs" + let bPath = dir `toAbsFp` "B.hs" + pPath = dir `toAbsFp` "P.hs" + aPath = dir `toAbsFp` "A.hs" bSource <- liftIO $ readFileUtf8 bPath -- y :: Int pSource <- liftIO $ readFileUtf8 pPath -- bar = x :: Int @@ -490,7 +489,7 @@ tests = testGroup "diagnostics" ] expectNoMoreDiagnostics 1 - , testSessionWait "deduplicate missing module diagnostics" $ do + , testWithDummyPluginEmpty "deduplicate missing module diagnostics" $ do let fooContent = T.unlines [ "module Foo() where" , "import MissingModule" ] doc <- createDoc "Foo.hs" "haskell" fooContent expectDiagnostics [("Foo.hs", [(DiagnosticSeverity_Error, (1,7), "Could not find module 'MissingModule'")])] @@ -578,8 +577,7 @@ cancellationTemplate (edit, undoEdit) mbKey = testCase (maybe "-" fst mbKey) $ r expectNoMoreDiagnostics 0.5 where -- similar to run except it disables kick - runTestNoKick s = withTempDir $ \dir -> runInDir' dir "." "." ["--test-no-kick"] s - + runTestNoKick s = runSessionWithServerInTmpDirCont True dummyPlugin def def def (mkIdeTestFs []) (const s) typeCheck doc = do WaitForIdeRuleResult {..} <- waitForAction "TypeCheck" doc liftIO $ assertBool "The file should typecheck" ideResultSuccess diff --git a/ghcide/test/exe/ExceptionTests.hs b/ghcide/test/exe/ExceptionTests.hs index 0de78ee562..6d19891978 100644 --- a/ghcide/test/exe/ExceptionTests.hs +++ b/ghcide/test/exe/ExceptionTests.hs @@ -31,6 +31,7 @@ import Language.LSP.Protocol.Types hiding mkRange) import Language.LSP.Test import LogType (Log (..)) +import Test.Hls (waitForProgressDone) import Test.Tasty import Test.Tasty.HUnit import TestUtils diff --git a/ghcide/test/exe/InitializeResponseTests.hs b/ghcide/test/exe/InitializeResponseTests.hs index bccf124c09..16e4e4b6f4 100644 --- a/ghcide/test/exe/InitializeResponseTests.hs +++ b/ghcide/test/exe/InitializeResponseTests.hs @@ -87,7 +87,7 @@ tests = withResource acquire release tests where innerCaps (TResponseMessage _ _ (Left _)) = error "Initialization error" acquire :: IO (TResponseMessage Method_Initialize) - acquire = runWithDummyPluginEmpty initializeResponse + acquire = runWithDummyPlugin (mkIdeTestFs []) initializeResponse release :: TResponseMessage Method_Initialize -> IO () release = mempty diff --git a/ghcide/test/exe/OpenCloseTest.hs b/ghcide/test/exe/OpenCloseTest.hs index 2c7237fc28..83a85520f2 100644 --- a/ghcide/test/exe/OpenCloseTest.hs +++ b/ghcide/test/exe/OpenCloseTest.hs @@ -6,11 +6,13 @@ import Control.Monad import Language.LSP.Protocol.Message import Language.LSP.Test -- import Test.QuickCheck.Instances () +import Config (testWithDummyPluginEmpty) +import Test.Hls (waitForProgressBegin, + waitForProgressDone) import Test.Tasty -import TestUtils tests :: TestTree -tests = testSession "open close" $ do +tests = testWithDummyPluginEmpty "open close" $ do doc <- createDoc "Testing.hs" "haskell" "" void (skipManyTill anyMessage $ message SMethod_WindowWorkDoneProgressCreate) waitForProgressBegin diff --git a/ghcide/test/exe/THTests.hs b/ghcide/test/exe/THTests.hs index dc781d90d2..038de5ce21 100644 --- a/ghcide/test/exe/THTests.hs +++ b/ghcide/test/exe/THTests.hs @@ -12,6 +12,8 @@ import Language.LSP.Protocol.Types hiding (SemanticTokenAbsolute (..), SemanticTokensEdit (..), mkRange) import Language.LSP.Test import System.FilePath +import Test.Hls (waitForAllProgressDone, + waitForProgressBegin) import Test.Tasty import Test.Tasty.HUnit import TestUtils diff --git a/ghcide/test/exe/TestUtils.hs b/ghcide/test/exe/TestUtils.hs index 140d48df10..60c98b5a41 100644 --- a/ghcide/test/exe/TestUtils.hs +++ b/ghcide/test/exe/TestUtils.hs @@ -40,33 +40,9 @@ import Test.Tasty import Test.Tasty.ExpectedFailure import Test.Tasty.HUnit +import Config (lspTestCaps) import LogType --- | Wait for the next progress begin step -waitForProgressBegin :: Session () -waitForProgressBegin = skipManyTill anyMessage $ satisfyMaybe $ \case - FromServerMess SMethod_Progress (TNotificationMessage _ _ (ProgressParams _ v)) | Lens.is _workDoneProgressBegin v-> Just () - _ -> Nothing - --- | Wait for the first progress end step --- Also implemented in hls-test-utils Test.Hls -waitForProgressDone :: Session () -waitForProgressDone = skipManyTill anyMessage $ satisfyMaybe $ \case - FromServerMess SMethod_Progress (TNotificationMessage _ _ (ProgressParams _ v)) | Lens.is _workDoneProgressEnd v -> Just () - _ -> Nothing - --- | Wait for all progress to be done --- Needs at least one progress done notification to return --- Also implemented in hls-test-utils Test.Hls -waitForAllProgressDone :: Session () -waitForAllProgressDone = loop - where - loop = do - ~() <- skipManyTill anyMessage $ satisfyMaybe $ \case - FromServerMess SMethod_Progress (TNotificationMessage _ _ (ProgressParams _ v)) |Lens.is _workDoneProgressEnd v-> Just () - _ -> Nothing - done <- null <$> getIncompleteProgressSessions - unless done loop run :: Session a -> IO a run s = run' (const s) @@ -122,9 +98,6 @@ withTempDir f = System.IO.Extra.withTempDir $ \dir -> do dir' <- canonicalizePath dir f dir' -lspTestCaps :: ClientCapabilities -lspTestCaps = fullCaps { _window = Just $ WindowClientCapabilities (Just True) Nothing Nothing } - getConfigFromEnv :: IO SessionConfig getConfigFromEnv = do logColor <- fromMaybe True <$> checkEnv "LSP_TEST_LOG_COLOR" @@ -231,11 +204,6 @@ copyTestDataFiles dir prefix = do withLongTimeout :: IO a -> IO a withLongTimeout = bracket_ (setEnv "LSP_TIMEOUT" "120" True) (unsetEnv "LSP_TIMEOUT") - - -lspTestCapsNoFileWatches :: ClientCapabilities -lspTestCapsNoFileWatches = lspTestCaps & L.workspace . Lens._Just . L.didChangeWatchedFiles .~ Nothing - testIde :: Recorder (WithPriority Log) -> IDE.Arguments -> Session () -> IO () testIde recorder arguments session = do config <- getConfigFromEnv diff --git a/ghcide/test/exe/UnitTests.hs b/ghcide/test/exe/UnitTests.hs index b798146fb0..4900b7cae4 100644 --- a/ghcide/test/exe/UnitTests.hs +++ b/ghcide/test/exe/UnitTests.hs @@ -30,6 +30,7 @@ import Network.URI import qualified Progress import System.IO.Extra hiding (withTempDir) import System.Mem (performGC) +import Test.Hls (waitForProgressDone) import Test.Tasty import Test.Tasty.ExpectedFailure import Test.Tasty.HUnit diff --git a/hls-test-utils/src/Test/Hls.hs b/hls-test-utils/src/Test/Hls.hs index 68efc4a47d..840ff6829e 100644 --- a/hls-test-utils/src/Test/Hls.hs +++ b/hls-test-utils/src/Test/Hls.hs @@ -34,7 +34,9 @@ module Test.Hls runSessionWithServer', runSessionWithServerInTmpDir', -- continuation version that take a FileSystem + runSessionWithServerInTmpDirCont, runSessionWithServerInTmpDirCont', + runSessionWithServerAndCapsInTmpDirCont, -- * Helpful re-exports PluginDescriptor, IdeState, @@ -42,6 +44,7 @@ module Test.Hls waitForProgressDone, waitForAllProgressDone, waitForBuildQueue, + waitForProgressBegin, waitForTypecheck, waitForAction, hlsConfigToClientConfig, @@ -51,7 +54,7 @@ module Test.Hls waitForKickStart, -- * Plugin descriptor helper functions for tests PluginTestDescriptor, - pluginTestRecorder, + hlsPluginTestRecorder, mkPluginTestDescriptor, mkPluginTestDescriptor', -- * Re-export logger types @@ -322,9 +325,28 @@ mkPluginTestDescriptor' -> PluginTestDescriptor b mkPluginTestDescriptor' pluginDesc plId _recorder = IdePlugins [pluginDesc plId] --- | Initialise a recorder that can be instructed to write to stderr by --- setting the environment variable "HLS_TEST_PLUGIN_LOG_STDERR=1" before --- running the tests. +-- | Initialize a recorder that can be instructed to write to stderr by +-- setting one of the environment variables: +-- +-- * HLS_TEST_HARNESS_STDERR=1 +-- * HLS_TEST_LOG_STDERR=1 +-- +-- "HLS_TEST_LOG_STDERR" is intended to enable all logging for the server and the plugins +-- under test. +hlsHelperTestRecorder :: Pretty a => IO (Recorder (WithPriority a)) +hlsHelperTestRecorder = initializeTestRecorder ["HLS_TEST_HARNESS_STDERR", "HLS_TEST_LOG_STDERR"] + + +-- | Initialize a recorder that can be instructed to write to stderr by +-- setting one of the environment variables: +-- +-- * HLS_TEST_PLUGIN_LOG_STDERR=1 +-- * HLS_TEST_LOG_STDERR=1 +-- +-- before running the tests. +-- +-- "HLS_TEST_LOG_STDERR" is intended to enable all logging for the server and the plugins +-- under test. -- -- On the cli, use for example: -- @@ -337,11 +359,10 @@ mkPluginTestDescriptor' pluginDesc plId _recorder = IdePlugins [pluginDesc plId] -- @ -- HLS_TEST_LOG_STDERR=1 cabal test -- @ -pluginTestRecorder :: Pretty a => IO (Recorder (WithPriority a)) -pluginTestRecorder = do - initialiseTestRecorder ["HLS_TEST_PLUGIN_LOG_STDERR", "HLS_TEST_LOG_STDERR"] +hlsPluginTestRecorder :: Pretty a => IO (Recorder (WithPriority a)) +hlsPluginTestRecorder = initializeTestRecorder ["HLS_TEST_PLUGIN_LOG_STDERR", "HLS_TEST_LOG_STDERR"] --- | Generic recorder initialisation for plugins and the HLS server for test-cases. +-- | Generic recorder initialization for plugins and the HLS server for test-cases. -- -- The created recorder writes to stderr if any of the given environment variables -- have been set to a value different to @0@. @@ -350,11 +371,11 @@ pluginTestRecorder = do -- -- We have to return the base logger function for HLS server logging initialisation. -- See 'runSessionWithServer'' for details. -initialiseTestRecorder :: Pretty a => [String] -> IO (Recorder (WithPriority a)) -initialiseTestRecorder envVars = do +initializeTestRecorder :: Pretty a => [String] -> IO (Recorder (WithPriority a)) +initializeTestRecorder envVars = do docWithPriorityRecorder <- makeDefaultStderrRecorder (Just $ ThreadIdColumn : defaultLoggingColumns) -- There are potentially multiple environment variables that enable this logger - definedEnvVars <- forM envVars (\var -> fromMaybe "0" <$> lookupEnv var) + definedEnvVars <- forM envVars (fmap (fromMaybe "0") . lookupEnv) let logStdErr = any (/= "0") definedEnvVars docWithFilteredPriorityRecorder = @@ -374,20 +395,16 @@ runSessionWithServerAndCapsInTmpDir config plugin caps tree act = runSessionWith runSessionWithServerInTmpDirCont' :: Pretty b => Config -> PluginTestDescriptor b -> VirtualFileTree -> (FileSystem -> Session a) -> IO a runSessionWithServerInTmpDirCont' config plugin tree act = do - recorder <- pluginTestRecorder - runSessionWithServerInTmpDirCont (plugin recorder) config def fullCaps tree act + runSessionWithServerInTmpDirCont False plugin config def fullCaps tree act runSessionWithServerAndCapsInTmpDirCont :: Pretty b => Config -> PluginTestDescriptor b -> ClientCapabilities -> VirtualFileTree -> (FileSystem -> Session a) -> IO a runSessionWithServerAndCapsInTmpDirCont config plugin caps tree act = do - recorder <- pluginTestRecorder - runSessionWithServerInTmpDirCont (plugin recorder) config def caps tree act + runSessionWithServerInTmpDirCont False plugin config def caps tree act runSessionWithServerInTmpDir' :: + Pretty b => -- | Plugins to load on the server. - -- - -- For improved logging, make sure these plugins have been initalised with - -- the recorder produced by @pluginTestRecorder@. - IdePlugins IdeState -> + PluginTestDescriptor b -> -- | lsp config for the server Config -> -- | config for the test session @@ -395,7 +412,7 @@ runSessionWithServerInTmpDir' :: ClientCapabilities -> VirtualFileTree -> Session a -> IO a -runSessionWithServerInTmpDir' plugins conf sessConf caps tree act = runSessionWithServerInTmpDirCont plugins conf sessConf caps tree (const act) +runSessionWithServerInTmpDir' plugins conf sessConf caps tree act = runSessionWithServerInTmpDirCont False plugins conf sessConf caps tree (const act) -- | Host a server, and run a test session on it. -- @@ -419,11 +436,11 @@ runSessionWithServerInTmpDir' plugins conf sessConf caps tree act = runSessionWi -- -- Note: cwd will be shifted into a temporary directory in @Session a@ runSessionWithServerInTmpDirCont :: + Pretty b => + -- | whether we disable the kick action or not + Bool -> -- | Plugins to load on the server. - -- - -- For improved logging, make sure these plugins have been initalised with - -- the recorder produced by @pluginTestRecorder@. - IdePlugins IdeState -> + PluginTestDescriptor b -> -- | lsp config for the server Config -> -- | config for the test session @@ -431,10 +448,9 @@ runSessionWithServerInTmpDirCont :: ClientCapabilities -> VirtualFileTree -> (FileSystem -> Session a) -> IO a -runSessionWithServerInTmpDirCont plugins conf sessConf caps tree act = withLock lockForTempDirs $ do +runSessionWithServerInTmpDirCont disableKick plugins conf sessConf caps tree act = withLock lockForTempDirs $ do testRoot <- setupTestEnvironment - recorder <- initialiseTestRecorder - ["LSP_TEST_LOG_STDERR", "HLS_TEST_HARNESS_STDERR", "HLS_TEST_LOG_STDERR"] + helperRecorder <- hlsHelperTestRecorder -- Do not clean up the temporary directory if this variable is set to anything but '0'. -- Aids debugging. @@ -443,32 +459,30 @@ runSessionWithServerInTmpDirCont plugins conf sessConf caps tree act = withLock Just val | val /= "0" -> do (tempDir, _) <- newTempDirWithin testRoot a <- action tempDir - logWith recorder Debug LogNoCleanup + logWith helperRecorder Debug LogNoCleanup pure a _ -> do (tempDir, cleanup) <- newTempDirWithin testRoot a <- action tempDir `finally` cleanup - logWith recorder Debug LogCleanup + logWith helperRecorder Debug LogCleanup pure a runTestInDir $ \tmpDir' -> do -- we canonicalize the path, so that we do not need to do -- cannibalization during the test when we compare two paths tmpDir <- canonicalizePath tmpDir' - logWith recorder Info $ LogTestDir tmpDir + logWith helperRecorder Info $ LogTestDir tmpDir fs <- FS.materialiseVFT tmpDir tree - runSessionWithServer' plugins conf sessConf caps tmpDir (act fs) + runSessionWithServer' disableKick plugins conf sessConf caps tmpDir (act fs) runSessionWithServer :: Pretty b => Config -> PluginTestDescriptor b -> FilePath -> Session a -> IO a runSessionWithServer config plugin fp act = do - recorder <- pluginTestRecorder - runSessionWithServer' (plugin recorder) config def fullCaps fp act + runSessionWithServer' False plugin config def fullCaps fp act runSessionWithServerAndCaps :: Pretty b => Config -> PluginTestDescriptor b -> ClientCapabilities -> FilePath -> Session a -> IO a runSessionWithServerAndCaps config plugin caps fp act = do - recorder <- pluginTestRecorder - runSessionWithServer' (plugin recorder) config def caps fp act + runSessionWithServer' False plugin config def caps fp act -- | Setup the test environment for isolated tests. @@ -605,11 +619,11 @@ lockForTempDirs = unsafePerformIO newLock -- | Host a server, and run a test session on it -- Note: cwd will be shifted into @root@ in @Session a@ runSessionWithServer' :: - -- | Plugins to load on the server. - -- - -- For improved logging, make sure these plugins have been initalised with - -- the recorder produced by @pluginTestRecorder@. - IdePlugins IdeState -> + (Pretty b) => + -- | whether we disable the kick action or not + Bool -> + -- | Plugin to load on the server. + PluginTestDescriptor b -> -- | lsp config for the server Config -> -- | config for the test session @@ -618,18 +632,13 @@ runSessionWithServer' :: FilePath -> Session a -> IO a -runSessionWithServer' plugins conf sconf caps root s = withLock lock $ keepCurrentDirectory $ do +runSessionWithServer' disableKick pluginsDp conf sconf caps root s = withLock lock $ keepCurrentDirectory $ do (inR, inW) <- createPipe (outR, outW) <- createPipe - -- Allow three environment variables, because "LSP_TEST_LOG_STDERR" has been used before, - -- (thus, backwards compatibility) and "HLS_TEST_SERVER_LOG_STDERR" because it - -- uses a more descriptive name. - -- It is also in better accordance with 'pluginTestRecorder' which uses "HLS_TEST_PLUGIN_LOG_STDERR". - -- At last, "HLS_TEST_LOG_STDERR" is intended to enable all logging for the server and the plugins - -- under test. - recorder <- initialiseTestRecorder - ["LSP_TEST_LOG_STDERR", "HLS_TEST_SERVER_LOG_STDERR", "HLS_TEST_LOG_STDERR"] + recorder <- hlsPluginTestRecorder + let plugins = pluginsDp recorder + recorderIde <- hlsHelperTestRecorder let sconf' = sconf { lspConfig = hlsConfigToClientConfig conf } @@ -637,7 +646,7 @@ runSessionWithServer' plugins conf sconf caps root s = withLock lock $ keepCurr hlsPlugins = IdePlugins [Test.blockCommandDescriptor "block-command"] <> plugins arguments@Arguments{ argsIdeOptions } = - testing (cmapWithPrio LogIDEMain recorder) hlsPlugins + testing (cmapWithPrio LogIDEMain recorderIde) hlsPlugins ideOptions config ghcSession = let defIdeOptions = argsIdeOptions config ghcSession @@ -647,13 +656,14 @@ runSessionWithServer' plugins conf sconf caps root s = withLock lock $ keepCurr } server <- async $ - IDEMain.defaultMain (cmapWithPrio LogIDEMain recorder) + IDEMain.defaultMain (cmapWithPrio LogIDEMain recorderIde) arguments { argsHandleIn = pure inR , argsHandleOut = pure outW , argsDefaultHlsConfig = conf , argsIdeOptions = ideOptions , argsProjectRoot = Just root + , argsDisableKick = disableKick } x <- runSessionWithHandles inW outR sconf' caps root s @@ -666,6 +676,12 @@ runSessionWithServer' plugins conf sconf caps root s = withLock lock $ keepCurr putStrLn $ "Finishing canceling (took " <> showDuration t <> "s)" pure x +-- | Wait for the next progress begin step +waitForProgressBegin :: Session () +waitForProgressBegin = skipManyTill anyMessage $ satisfyMaybe $ \case + FromServerMess SMethod_Progress (TNotificationMessage _ _ (ProgressParams _ v)) | is _workDoneProgressBegin v-> Just () + _ -> Nothing + -- | Wait for the next progress end step waitForProgressDone :: Session () waitForProgressDone = skipManyTill anyMessage $ satisfyMaybe $ \case diff --git a/plugins/hls-refactor-plugin/test/Main.hs b/plugins/hls-refactor-plugin/test/Main.hs index 092cd6ef0b..3670a3b398 100644 --- a/plugins/hls-refactor-plugin/test/Main.hs +++ b/plugins/hls-refactor-plugin/test/Main.hs @@ -27,7 +27,6 @@ import Development.IDE.Plugin.Completions.Types (extendImportCommandId import Development.IDE.Test import Development.IDE.Types.Location import Development.Shake (getDirectoryFilesIO) -import Ide.Types import qualified Language.LSP.Protocol.Lens as L import Language.LSP.Protocol.Message import Language.LSP.Protocol.Types hiding @@ -48,24 +47,21 @@ import Text.Regex.TDFA ((=~)) import Development.IDE.Plugin.CodeAction (matchRegExMultipleImports) import Test.Hls +import qualified Development.IDE.GHC.ExactPrint import qualified Development.IDE.Plugin.CodeAction as Refactor -import qualified Development.IDE.Plugin.HLS.GhcIde as GhcIde import qualified Test.AddArgument main :: IO () main = defaultTestRunner tests -refactorPlugin :: IO (IdePlugins IdeState) +refactorPlugin :: PluginTestDescriptor Development.IDE.GHC.ExactPrint.Log refactorPlugin = do - exactprintLog <- pluginTestRecorder - ghcideLog <- pluginTestRecorder - pure $ IdePlugins $ - [ Refactor.iePluginDescriptor exactprintLog "ghcide-code-actions-imports-exports" - , Refactor.typeSigsPluginDescriptor exactprintLog "ghcide-code-actions-type-signatures" - , Refactor.bindingsPluginDescriptor exactprintLog "ghcide-code-actions-bindings" - , Refactor.fillHolePluginDescriptor exactprintLog "ghcide-code-actions-fill-holes" - , Refactor.extendImportPluginDescriptor exactprintLog "ghcide-completions-1" - ] ++ GhcIde.descriptors ghcideLog + mkPluginTestDescriptor Refactor.iePluginDescriptor "ghcide-code-actions-imports-exports" + <> mkPluginTestDescriptor Refactor.typeSigsPluginDescriptor "ghcide-code-actions-type-signatures" + <> mkPluginTestDescriptor Refactor.bindingsPluginDescriptor "ghcide-code-actions-bindings" + <> mkPluginTestDescriptor Refactor.fillHolePluginDescriptor "ghcide-code-actions-fill-holes" + <> mkPluginTestDescriptor Refactor.extendImportPluginDescriptor "ghcide-completions-1" + tests :: TestTree tests = @@ -3755,9 +3751,7 @@ run' :: (FilePath -> Session a) -> IO a run' s = withTempDir $ \dir -> runInDir dir (s dir) runInDir :: FilePath -> Session a -> IO a -runInDir dir act = do - plugin <- refactorPlugin - runSessionWithServer' plugin def def lspTestCaps dir act +runInDir dir act = runSessionWithServerAndCaps def refactorPlugin lspTestCaps dir act lspTestCaps :: ClientCapabilities lspTestCaps = fullCaps { _window = Just $ WindowClientCapabilities (Just True) Nothing Nothing } diff --git a/plugins/hls-semantic-tokens-plugin/test/SemanticTokensTest.hs b/plugins/hls-semantic-tokens-plugin/test/SemanticTokensTest.hs index 2cac6e597c..906319ed2a 100644 --- a/plugins/hls-semantic-tokens-plugin/test/SemanticTokensTest.hs +++ b/plugins/hls-semantic-tokens-plugin/test/SemanticTokensTest.hs @@ -40,7 +40,6 @@ import Test.Hls (HasCallStack, documentContents, fullCaps, goldenGitDiff, mkPluginTestDescriptor, - pluginTestRecorder, runSessionWithServerInTmpDir, runSessionWithServerInTmpDir', testCase, testGroup, @@ -157,9 +156,8 @@ semanticTokensConfigTest = var :: String var = "variable" do - recorder <- pluginTestRecorder Test.Hls.runSessionWithServerInTmpDir' - (semanticTokensPlugin recorder) + semanticTokensPlugin (mkSemanticConfig funcVar) def {ignoreConfigurationRequests = False} fullCaps diff --git a/test/functional/Config.hs b/test/functional/Config.hs index 89aa466a0f..1dbf12c64c 100644 --- a/test/functional/Config.hs +++ b/test/functional/Config.hs @@ -68,8 +68,7 @@ genericConfigTests = testGroup "generic plugin config" testPluginDiagnostics = [("Foo.hs", [(DiagnosticSeverity_Error, (0,0), "testplugin")])] runConfigSession subdir session = do - recorder <- pluginTestRecorder - failIfSessionTimeout $ runSessionWithServer' @() (plugin recorder) def (def {ignoreConfigurationRequests=False}) fullCaps ("test/testdata" subdir) session + failIfSessionTimeout $ runSessionWithServer' @() False plugin def (def {ignoreConfigurationRequests=False}) fullCaps ("test/testdata" subdir) session testPluginId = "testplugin" -- A disabled-by-default plugin that creates diagnostics