-
-
Notifications
You must be signed in to change notification settings - Fork 391
[Migrate diagnosticTests] part of #4173 Migrate ghcide tests to hls test utils #4207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
361131e
fa0e4de
ef077d2
cc7d3cb
b887243
158caa9
56195f5
b8c6ca9
46b5f04
1554f87
4388ac0
f6a7f48
aee5c53
8aa41f3
7d22fb7
cfd3f53
d40c643
a03aa22
e2a50f2
5ffbf2f
c8aa5ca
1f7f49f
d08228d
354854e
726a88d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 () | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW, I'm not sure all these functions are necessarily worth it. How bad would it be to just have the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Emm, we are at somewhat funny situation, that the one without the extra FileSystem are the most used. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess I'm wondering how bad it would be. Otherwise we have a lot of very similar variant functions 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a blocker, anyway There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, I mean since we have a lot of test that does not need the That is why I want to either do the typeclass polymorphic or just duplicate the test runner function variant. |
||
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 |
Uh oh!
There was an error while loading. Please reload this page.