mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-04 04:40:56 -06:00
Server: test cache after reconnect
This commit is contained in:
@@ -20,6 +20,7 @@ macro(do_test bsname file)
|
|||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
do_test("test_cache" "tc_cache.json")
|
||||||
do_test("test_handshake" "tc_handshake.json")
|
do_test("test_handshake" "tc_handshake.json")
|
||||||
do_test("test_globalSettings" "tc_globalSettings.json")
|
do_test("test_globalSettings" "tc_globalSettings.json")
|
||||||
do_test("test_buildsystem1" "tc_buildsystem1.json")
|
do_test("test_buildsystem1" "tc_buildsystem1.json")
|
||||||
|
|||||||
@@ -95,6 +95,21 @@ def initProc(cmakeCommand):
|
|||||||
|
|
||||||
return cmakeCommand
|
return cmakeCommand
|
||||||
|
|
||||||
|
def exitProc(cmakeCommand):
|
||||||
|
# Tell the server to exit.
|
||||||
|
cmakeCommand.stdin.close()
|
||||||
|
cmakeCommand.stdout.close()
|
||||||
|
|
||||||
|
# Wait for the server to exit.
|
||||||
|
# If this version of python supports it, terminate the server after a timeout.
|
||||||
|
try:
|
||||||
|
cmakeCommand.wait(timeout=5)
|
||||||
|
except TypeError:
|
||||||
|
cmakeCommand.wait()
|
||||||
|
except:
|
||||||
|
cmakeCommand.terminate()
|
||||||
|
raise
|
||||||
|
|
||||||
def waitForMessage(cmakeCommand, expected):
|
def waitForMessage(cmakeCommand, expected):
|
||||||
data = ordered(expected)
|
data = ordered(expected)
|
||||||
packet = ordered(waitForRawMessage(cmakeCommand))
|
packet = ordered(waitForRawMessage(cmakeCommand))
|
||||||
@@ -197,3 +212,27 @@ def validateGlobalSettings(cmakeCommand, cmakeCommandPath, data):
|
|||||||
print("Validating", i)
|
print("Validating", i)
|
||||||
if (packet[i] != data[i]):
|
if (packet[i] != data[i]):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
def validateCache(cmakeCommand, data):
|
||||||
|
packet = waitForReply(cmakeCommand, 'cache', '', False)
|
||||||
|
|
||||||
|
cache = packet['cache']
|
||||||
|
|
||||||
|
if (data['isEmpty']):
|
||||||
|
if (cache != []):
|
||||||
|
print('Expected empty cache, but got data.\n')
|
||||||
|
sys.exit(1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (cache == []):
|
||||||
|
print('Expected cache contents, but got none.\n')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
hadHomeDir = False
|
||||||
|
for value in cache:
|
||||||
|
if (value['key'] == 'CMAKE_HOME_DIRECTORY'):
|
||||||
|
hadHomeDir = True
|
||||||
|
|
||||||
|
if (not hadHomeDir):
|
||||||
|
print('No CMAKE_HOME_DIRECTORY found in cache.')
|
||||||
|
sys.exit(1)
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ for obj in testData:
|
|||||||
if 'extraGenerator' in data: extraGenerator = data['extraGenerator']
|
if 'extraGenerator' in data: extraGenerator = data['extraGenerator']
|
||||||
if not os.path.isabs(buildDirectory):
|
if not os.path.isabs(buildDirectory):
|
||||||
buildDirectory = buildDir + "/" + buildDirectory
|
buildDirectory = buildDir + "/" + buildDirectory
|
||||||
if not os.path.isabs(sourceDirectory):
|
if sourceDirectory != '' and not os.path.isabs(sourceDirectory):
|
||||||
sourceDirectory = sourceDir + "/" + sourceDirectory
|
sourceDirectory = sourceDir + "/" + sourceDirectory
|
||||||
cmakelib.handshake(proc, major, minor, sourceDirectory, buildDirectory,
|
cmakelib.handshake(proc, major, minor, sourceDirectory, buildDirectory,
|
||||||
generator, extraGenerator)
|
generator, extraGenerator)
|
||||||
@@ -95,26 +95,20 @@ for obj in testData:
|
|||||||
if not 'generator' in data: data['generator'] = cmakeGenerator
|
if not 'generator' in data: data['generator'] = cmakeGenerator
|
||||||
if not 'extraGenerator' in data: data['extraGenerator'] = ''
|
if not 'extraGenerator' in data: data['extraGenerator'] = ''
|
||||||
cmakelib.validateGlobalSettings(proc, cmakeCommand, data)
|
cmakelib.validateGlobalSettings(proc, cmakeCommand, data)
|
||||||
|
elif 'validateCache' in obj:
|
||||||
|
data = obj['validateCache']
|
||||||
|
if not 'isEmpty' in data: data['isEmpty'] = false
|
||||||
|
cmakelib.validateCache(proc, data)
|
||||||
elif 'message' in obj:
|
elif 'message' in obj:
|
||||||
print("MESSAGE:", obj["message"])
|
print("MESSAGE:", obj["message"])
|
||||||
|
elif 'reconnect' in obj:
|
||||||
|
cmakelib.exitProc(proc)
|
||||||
|
proc = cmakelib.initProc(cmakeCommand)
|
||||||
else:
|
else:
|
||||||
print("Unknown command:", json.dumps(obj))
|
print("Unknown command:", json.dumps(obj))
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
print("Completed")
|
print("Completed")
|
||||||
|
|
||||||
# Tell the server to exit.
|
cmakelib.exitProc(proc)
|
||||||
proc.stdin.close()
|
|
||||||
proc.stdout.close()
|
|
||||||
|
|
||||||
# Wait for the server to exit.
|
|
||||||
# If this version of python supports it, terminate the server after a timeout.
|
|
||||||
try:
|
|
||||||
proc.wait(timeout=5)
|
|
||||||
except TypeError:
|
|
||||||
proc.wait()
|
|
||||||
except:
|
|
||||||
proc.terminate()
|
|
||||||
raise
|
|
||||||
|
|
||||||
sys.exit(proc.returncode)
|
sys.exit(proc.returncode)
|
||||||
|
|||||||
24
Tests/Server/tc_cache.json
Normal file
24
Tests/Server/tc_cache.json
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
[
|
||||||
|
{ "message": "Testing cache" },
|
||||||
|
|
||||||
|
{ "message": "Cache after first handshake is empty:" },
|
||||||
|
{ "handshake": {"major": 1, "sourceDirectory": "buildsystem1", "buildDirectory": "buildsystem1"} },
|
||||||
|
{ "send": { "type": "cache" } },
|
||||||
|
{ "validateCache": { "isEmpty": true } },
|
||||||
|
|
||||||
|
{ "message": "Cache after configure is populated:" },
|
||||||
|
{ "send": { "type": "configure" } },
|
||||||
|
{ "reply": { "type": "configure", "skipProgress":true } },
|
||||||
|
{ "send": { "type": "cache" } },
|
||||||
|
{ "validateCache": { "isEmpty": false } },
|
||||||
|
|
||||||
|
{ "message": "Handshake for existing cache requires buildDirectory only:" },
|
||||||
|
{ "reconnect": {} },
|
||||||
|
{ "handshake": {"major": 1, "sourceDirectory": "", "buildDirectory": "buildsystem1"} },
|
||||||
|
|
||||||
|
{ "message": "Cache after reconnect is again populated:" },
|
||||||
|
{ "send": { "type": "cache" } },
|
||||||
|
{ "validateCache": { "isEmpty": false } },
|
||||||
|
|
||||||
|
{ "message": "Everything ok." }
|
||||||
|
]
|
||||||
@@ -11,6 +11,10 @@
|
|||||||
{ "send": {"test": "sometext","cookie":"monster"} },
|
{ "send": {"test": "sometext","cookie":"monster"} },
|
||||||
{ "recv": {"cookie":"monster","errorMessage":"No type given in request.","inReplyTo":"","type":"error"} },
|
{ "recv": {"cookie":"monster","errorMessage":"No type given in request.","inReplyTo":"","type":"error"} },
|
||||||
|
|
||||||
|
{ "message": "Testing commands before handshake" },
|
||||||
|
{ "send": {"type": "cache","cookie":"monster"} },
|
||||||
|
{ "recv": {"cookie":"monster","errorMessage":"Waiting for type \"handshake\".","inReplyTo":"cache","type":"error"} },
|
||||||
|
|
||||||
{ "message": "Testing handshake" },
|
{ "message": "Testing handshake" },
|
||||||
{ "send": {"type": "sometype","cookie":"monster2"} },
|
{ "send": {"type": "sometype","cookie":"monster2"} },
|
||||||
{ "recv": {"cookie":"monster2","errorMessage":"Waiting for type \"handshake\".","inReplyTo":"sometype","type":"error"} },
|
{ "recv": {"cookie":"monster2","errorMessage":"Waiting for type \"handshake\".","inReplyTo":"sometype","type":"error"} },
|
||||||
|
|||||||
Reference in New Issue
Block a user