@@ -474,6 +474,8 @@ runSessionWithServer config plugin fp act =
474474instance Default (TestConfig b ) where
475475 def = TestConfig {
476476 testDirLocation = Right $ VirtualFileTree [] " " ,
477+ testClientRoot = Nothing ,
478+ testServerRoot = Nothing ,
477479 testShiftRoot = False ,
478480 testDisableKick = False ,
479481 testDisableDefaultPlugin = False ,
@@ -618,6 +620,7 @@ lockForTempDirs = unsafePerformIO newLock
618620data TestConfig b = TestConfig
619621 {
620622 testDirLocation :: Either FilePath VirtualFileTree
623+ -- ^ Client capabilities
621624 -- ^ The file tree to use for the test, either a directory or a virtual file tree
622625 -- if using a virtual file tree,
623626 -- Creates a temporary directory, and materializes the VirtualFileTree
@@ -638,6 +641,15 @@ data TestConfig b = TestConfig
638641 -- For plugin test logs, look at the documentation of 'mkPluginTestDescriptor'.
639642 , testShiftRoot :: Bool
640643 -- ^ Whether to shift the current directory to the root of the project
644+ , testClientRoot :: Maybe FilePath
645+ -- ^ Specify the root of (the client or LSP context),
646+ -- if Nothing it is the same as the testDirLocation
647+ -- if Just, it is subdirectory of the testDirLocation
648+ , testServerRoot :: Maybe FilePath
649+ -- ^ Specify root of the server, in exe, it can be specify in command line --cwd,
650+ -- or just the server start directory
651+ -- if Nothing it is the same as the testDirLocation
652+ -- if Just, it is subdirectory of the testDirLocation
641653 , testDisableKick :: Bool
642654 -- ^ Whether to disable the kick action
643655 , testDisableDefaultPlugin :: Bool
@@ -671,6 +683,8 @@ runSessionWithTestConfig TestConfig{..} session =
671683 runSessionInVFS testDirLocation $ \ root -> shiftRoot root $ do
672684 (inR, inW) <- createPipe
673685 (outR, outW) <- createPipe
686+ let serverRoot = fromMaybe root testServerRoot
687+ let clientRoot = fromMaybe root testClientRoot
674688
675689 (recorder, cb1) <- wrapClientLogger =<< hlsPluginTestRecorder
676690 (recorderIde, cb2) <- wrapClientLogger =<< hlsHelperTestRecorder
@@ -685,11 +699,11 @@ runSessionWithTestConfig TestConfig{..} session =
685699 let plugins = testPluginDescriptor recorder <> lspRecorderPlugin
686700 timeoutOverride <- fmap read <$> lookupEnv " LSP_TIMEOUT"
687701 let sconf' = testConfigSession { lspConfig = hlsConfigToClientConfig testLspConfig, messageTimeout = fromMaybe (messageTimeout defaultConfig) timeoutOverride}
688- arguments = testingArgs root recorderIde plugins
702+ arguments = testingArgs serverRoot recorderIde plugins
689703 server <- async $
690704 IDEMain. defaultMain (cmapWithPrio LogIDEMain recorderIde)
691705 arguments { argsHandleIn = pure inR , argsHandleOut = pure outW }
692- result <- runSessionWithHandles inW outR sconf' testConfigCaps root (session root)
706+ result <- runSessionWithHandles inW outR sconf' testConfigCaps clientRoot (session root)
693707 hClose inW
694708 timeout 3 (wait server) >>= \ case
695709 Just () -> pure ()
0 commit comments