@@ -474,6 +474,8 @@ runSessionWithServer config plugin fp act =
474
474
instance Default (TestConfig b ) where
475
475
def = TestConfig {
476
476
testDirLocation = Right $ VirtualFileTree [] " " ,
477
+ testClientRoot = Nothing ,
478
+ testServerRoot = Nothing ,
477
479
testShiftRoot = False ,
478
480
testDisableKick = False ,
479
481
testDisableDefaultPlugin = False ,
@@ -618,6 +620,7 @@ lockForTempDirs = unsafePerformIO newLock
618
620
data TestConfig b = TestConfig
619
621
{
620
622
testDirLocation :: Either FilePath VirtualFileTree
623
+ -- ^ Client capabilities
621
624
-- ^ The file tree to use for the test, either a directory or a virtual file tree
622
625
-- if using a virtual file tree,
623
626
-- Creates a temporary directory, and materializes the VirtualFileTree
@@ -638,6 +641,15 @@ data TestConfig b = TestConfig
638
641
-- For plugin test logs, look at the documentation of 'mkPluginTestDescriptor'.
639
642
, testShiftRoot :: Bool
640
643
-- ^ 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
641
653
, testDisableKick :: Bool
642
654
-- ^ Whether to disable the kick action
643
655
, testDisableDefaultPlugin :: Bool
@@ -671,6 +683,8 @@ runSessionWithTestConfig TestConfig{..} session =
671
683
runSessionInVFS testDirLocation $ \ root -> shiftRoot root $ do
672
684
(inR, inW) <- createPipe
673
685
(outR, outW) <- createPipe
686
+ let serverRoot = fromMaybe root testServerRoot
687
+ let clientRoot = fromMaybe root testClientRoot
674
688
675
689
(recorder, cb1) <- wrapClientLogger =<< hlsPluginTestRecorder
676
690
(recorderIde, cb2) <- wrapClientLogger =<< hlsHelperTestRecorder
@@ -685,11 +699,11 @@ runSessionWithTestConfig TestConfig{..} session =
685
699
let plugins = testPluginDescriptor recorder <> lspRecorderPlugin
686
700
timeoutOverride <- fmap read <$> lookupEnv " LSP_TIMEOUT"
687
701
let sconf' = testConfigSession { lspConfig = hlsConfigToClientConfig testLspConfig, messageTimeout = fromMaybe (messageTimeout defaultConfig) timeoutOverride}
688
- arguments = testingArgs root recorderIde plugins
702
+ arguments = testingArgs serverRoot recorderIde plugins
689
703
server <- async $
690
704
IDEMain. defaultMain (cmapWithPrio LogIDEMain recorderIde)
691
705
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)
693
707
hClose inW
694
708
timeout 3 (wait server) >>= \ case
695
709
Just () -> pure ()
0 commit comments