From 1146920bc9ed9bef2b5bb91b3cdec4700eb09881 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 8 Jun 2022 11:54:27 -0700 Subject: Add smoke test for language server. (#2266) --- tools/slang-test/test-context.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tools/slang-test/test-context.cpp') 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& out return SLANG_OK; } +SlangResult TestContext::createLanguageServerJSONRPCConnection(RefPtr& out) +{ + RefPtr 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 readStream( + new BufferedReadStream(process->getStream(StdStreamType::Out))); + + RefPtr connection = new HTTPPacketConnection(readStream, writeStream); + RefPtr rpcConnection = new JSONRPCConnection; + + SLANG_RETURN_ON_FAIL( + rpcConnection->init(connection, JSONRPCConnection::CallStyle::Object, process)); + + out = rpcConnection; + + return SLANG_OK; +} void TestContext::destroyRPCConnection() { -- cgit v1.2.3