diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/slang-test/slang-test-main.cpp | 17 | ||||
| -rw-r--r-- | tools/slang-test/test-context.cpp | 7 | ||||
| -rw-r--r-- | tools/slang-test/test-context.h | 1 |
3 files changed, 20 insertions, 5 deletions
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp index 355f28a23..6391ad3e2 100644 --- a/tools/slang-test/slang-test-main.cpp +++ b/tools/slang-test/slang-test-main.cpp @@ -1465,16 +1465,18 @@ TestResult runExecutableTest(TestContext* context, TestInput& input) TestResult runLanguageServerTest(TestContext* context, TestInput& input) { - RefPtr<JSONRPCConnection> connection; - if (SLANG_FAILED(context->createLanguageServerJSONRPCConnection(connection))) + if (!context->m_languageServerConnection) { - return TestResult::Fail; + if (SLANG_FAILED(context->createLanguageServerJSONRPCConnection(context->m_languageServerConnection))) + { + return TestResult::Fail; + } } if (context->isCollectingRequirements()) { - connection->sendCall(LanguageServerProtocol::ExitParams::methodName, JSONValue::makeInt(0)); return TestResult::Pass; } + auto connection = context->m_languageServerConnection.Ptr(); LanguageServerProtocol::InitializeParams initParams; LanguageServerProtocol::WorkspaceFolder wsFolder; wsFolder.name = "test"; @@ -1684,7 +1686,12 @@ TestResult runLanguageServerTest(TestContext* context, TestInput& input) } } } - connection->sendCall(LanguageServerProtocol::ExitParams::methodName, JSONValue::makeInt(0)); + LanguageServerProtocol::DidCloseTextDocumentParams closeDocParams; + closeDocParams.textDocument.uri = URI::fromLocalFilePath(fullPath.getUnownedSlice()).uri; + connection->sendCall( + LanguageServerProtocol::DidCloseTextDocumentParams::methodName, + &closeDocParams, + JSONValue::makeInt(1)); auto outputStem = input.outputStem; String expectedOutputPath = outputStem + ".expected.txt"; diff --git a/tools/slang-test/test-context.cpp b/tools/slang-test/test-context.cpp index 6bf7406e6..df472d11d 100644 --- a/tools/slang-test/test-context.cpp +++ b/tools/slang-test/test-context.cpp @@ -6,6 +6,7 @@ #include "../../source/core/slang-shared-library.h" #include "../../source/core/slang-test-tool-util.h" +#include "../../source/compiler-core/slang-language-server-protocol.h" #include <stdio.h> #include <stdlib.h> @@ -71,6 +72,12 @@ Result TestContext::init(const char* exePath) TestContext::~TestContext() { + if (m_languageServerConnection) + { + m_languageServerConnection->sendCall( + LanguageServerProtocol::ExitParams::methodName, + JSONValue::makeInt(0)); + } if (m_session) { spDestroySession(m_session); diff --git a/tools/slang-test/test-context.h b/tools/slang-test/test-context.h index 284206efb..faf115ba8 100644 --- a/tools/slang-test/test-context.h +++ b/tools/slang-test/test-context.h @@ -165,6 +165,7 @@ class TestContext SlangResult createLanguageServerJSONRPCConnection(Slang::RefPtr<Slang::JSONRPCConnection>& out); std::mutex mutex; + Slang::RefPtr<Slang::JSONRPCConnection> m_languageServerConnection; protected: SlangResult _createJSONRPCConnection(Slang::RefPtr<Slang::JSONRPCConnection>& out); |
