summaryrefslogtreecommitdiffstats
path: root/tools/slang-test/test-context.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-06-08 11:54:27 -0700
committerGitHub <noreply@github.com>2022-06-08 11:54:27 -0700
commit1146920bc9ed9bef2b5bb91b3cdec4700eb09881 (patch)
treee8d94a3aad0d204f7c33f38b42b9e03d862cc3c8 /tools/slang-test/test-context.cpp
parentff2ae7e0c1b48fa222f14dc84f15d0178ed056a1 (diff)
Add smoke test for language server. (#2266)
Diffstat (limited to 'tools/slang-test/test-context.cpp')
-rw-r--r--tools/slang-test/test-context.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/slang-test/test-context.cpp b/tools/slang-test/test-context.cpp
index cdafbc30d..6bf7406e6 100644
--- a/tools/slang-test/test-context.cpp
+++ b/tools/slang-test/test-context.cpp
@@ -171,6 +171,30 @@ SlangResult TestContext::_createJSONRPCConnection(RefPtr<JSONRPCConnection>& out
return SLANG_OK;
}
+SlangResult TestContext::createLanguageServerJSONRPCConnection(RefPtr<JSONRPCConnection>& out)
+{
+ RefPtr<Process> process;
+
+ {
+ CommandLine cmdLine;
+ cmdLine.setExecutableLocation(ExecutableLocation(exeDirectoryPath, "slangd"));
+ SLANG_RETURN_ON_FAIL(Process::create(cmdLine, Process::Flag::AttachDebugger, process));
+ }
+
+ Stream* writeStream = process->getStream(StdStreamType::In);
+ RefPtr<BufferedReadStream> readStream(
+ new BufferedReadStream(process->getStream(StdStreamType::Out)));
+
+ RefPtr<HTTPPacketConnection> connection = new HTTPPacketConnection(readStream, writeStream);
+ RefPtr<JSONRPCConnection> rpcConnection = new JSONRPCConnection;
+
+ SLANG_RETURN_ON_FAIL(
+ rpcConnection->init(connection, JSONRPCConnection::CallStyle::Object, process));
+
+ out = rpcConnection;
+
+ return SLANG_OK;
+}
void TestContext::destroyRPCConnection()
{