From 09552143be56ecbb073cb159cb1be6fd41ebcafb Mon Sep 17 00:00:00 2001 From: Richard Howell Date: Wed, 28 Aug 2019 11:01:25 -0700 Subject: [PATCH] handle lifecycle in test server correctly --- .../server.py | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Tests/INPUTS/BuildServerBuildSystemTests.testServerInitialize/server.py b/Tests/INPUTS/BuildServerBuildSystemTests.testServerInitialize/server.py index 7329895e..aea09381 100755 --- a/Tests/INPUTS/BuildServerBuildSystemTests.testServerInitialize/server.py +++ b/Tests/INPUTS/BuildServerBuildSystemTests.testServerInitialize/server.py @@ -14,6 +14,7 @@ while True: sys.stdin.readline() message = json.loads(sys.stdin.read(length)) + response = None if message["method"] == "build/initialize": response = { "jsonrpc": "2.0", @@ -29,18 +30,28 @@ while True: } } } - # ignore notifications + elif message["method"] == "build/initialized": + continue + elif message["method"] == "build/shutdown": + response = { + "jsonrpc": "2.0", + "id": message["id"], + "result": None + } + elif message["method"] == "build/exit": + break + # ignore other notifications elif "id" in message: response = { "jsonrpc": "2.0", "id": message["id"], "error": { "code": 123, - "message": "unhandled method", + "message": "unhandled method {}".format(message["method"]), } } - responseStr = json.dumps(response) - sys.stdout.write("Content-Length: {}\r\n\r\n{}".format(len(responseStr), responseStr)) - sys.stdout.flush() - + if response: + responseStr = json.dumps(response) + sys.stdout.write("Content-Length: {}\r\n\r\n{}".format(len(responseStr), responseStr)) + sys.stdout.flush()