summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-11-24 19:37:24 -0500
committerGitHub <noreply@github.com>2021-11-24 19:37:24 -0500
commitdd18f2bff2abd13548742e30c25a31b9ea9a0cbd (patch)
tree06de0ec6e90bcd47ab2600fc5c239608a7349324 /tools
parent233635c9324ca2ed3ca6ba1231ac5c73facb9fb2 (diff)
JSON-RPC make id explicit (#2030)
* #include an absolute path didn't work - because paths were taken to always be relative. * Use PersistantJSONValue for id storage. * Make id handling explicit - so can make message processing disjoint from receiving order. * Fix some issues on linux with templates. * Fix typo. * Fix call not passing id for JSON-RPC. * Simplify getting persistent id from JSONRPCConnection.
Diffstat (limited to 'tools')
-rw-r--r--tools/test-server/test-server-main.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/tools/test-server/test-server-main.cpp b/tools/test-server/test-server-main.cpp
index 2a2f65f31..a32d8c542 100644
--- a/tools/test-server/test-server-main.cpp
+++ b/tools/test-server/test-server-main.cpp
@@ -339,12 +339,12 @@ SlangResult TestServer::_executeSingle()
}
else
{
- return m_connection->sendError(JSONRPC::ErrorCode::MethodNotFound);
+ return m_connection->sendError(JSONRPC::ErrorCode::MethodNotFound, call.id);
}
}
default:
{
- return m_connection->sendError(JSONRPC::ErrorCode::ParseError);
+ return m_connection->sendError(JSONRPC::ErrorCode::InvalidRequest, m_connection->getCurrentMessageId());
}
}
@@ -368,8 +368,10 @@ static Index _findTestIndex(IUnitTestModule* testModule, const String& name)
SlangResult TestServer::_executeUnitTest(const JSONRPCCall& call)
{
+ auto id = m_connection->getPersistentValue(call.id);
+
TestServerProtocol::ExecuteUnitTestArgs args;
- SLANG_RETURN_ON_FAIL(m_connection->toNativeOrSendError(call.params, &args));
+ SLANG_RETURN_ON_FAIL(m_connection->toNativeOrSendError(call.params, &args, call.id));
auto sink = m_connection->getSink();
@@ -377,14 +379,14 @@ SlangResult TestServer::_executeUnitTest(const JSONRPCCall& call)
if (!testModule)
{
sink->diagnose(SourceLoc(), ServerDiagnostics::unableToFindUnitTestModule, args.moduleName);
- return m_connection->sendError(JSONRPC::ErrorCode::InvalidParams);
+ return m_connection->sendError(JSONRPC::ErrorCode::InvalidParams, id);
}
const Index testIndex = _findTestIndex(testModule, args.testName);
if (testIndex < 0)
{
sink->diagnose(SourceLoc(), ServerDiagnostics::unableToFindTest, args.testName);
- return m_connection->sendError(JSONRPC::ErrorCode::InvalidParams);
+ return m_connection->sendError(JSONRPC::ErrorCode::InvalidParams, id);
}
TestReporter testReporter;
@@ -432,21 +434,23 @@ SlangResult TestServer::_executeUnitTest(const JSONRPCCall& call)
}
result.returnCode = int32_t(TestToolUtil::getReturnCode(result.result));
- return m_connection->sendResult(&result, m_connection->getMessageId());
+ return m_connection->sendResult(&result, id);
}
SlangResult TestServer::_executeTool(const JSONRPCCall& call)
{
+ auto id = m_connection->getPersistentValue(call.id);
+
TestServerProtocol::ExecuteToolTestArgs args;
- SLANG_RETURN_ON_FAIL(m_connection->toNativeOrSendError(call.params, &args));
+ SLANG_RETURN_ON_FAIL(m_connection->toNativeOrSendError(call.params, &args, id));
auto sink = m_connection->getSink();
auto func = getToolFunction(args.toolName, sink);
if (!func)
{
- return m_connection->sendError(JSONRPC::ErrorCode::InvalidParams);
+ return m_connection->sendError(JSONRPC::ErrorCode::InvalidParams, id);
}
// Assume we will used the shared session
@@ -493,7 +497,7 @@ SlangResult TestServer::_executeTool(const JSONRPCCall& call)
result.stdOut = stdOut;
result.returnCode = int32_t(TestToolUtil::getReturnCode(result.result));
- return m_connection->sendResult(&result);
+ return m_connection->sendResult(&result, id);
}
SlangResult TestServer::execute()