diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2016-09-09 08:01:45 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-09-26 18:23:53 (GMT) |
commit | 82104cc7a8e831ad20cb87d126c2ff00a851bedc (patch) | |
tree | 79f319287f1f7370676cc69f0280e68fd46e42c1 /Tests/Server | |
parent | 1a5fddfe6d56733528ace3d15899b0739ea28054 (diff) | |
download | CMake-82104cc7a8e831ad20cb87d126c2ff00a851bedc.zip CMake-82104cc7a8e831ad20cb87d126c2ff00a851bedc.tar.gz CMake-82104cc7a8e831ad20cb87d126c2ff00a851bedc.tar.bz2 |
server-mode: Query global configuration of cmake via a command
Add "globalSettings" command that returns:
* Return capability information
* Return currently used generator/extra generator
* Return a range of flags for debug/trace/etc.
Diffstat (limited to 'Tests/Server')
-rw-r--r-- | Tests/Server/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/Server/cmakelib.py | 61 | ||||
-rw-r--r-- | Tests/Server/server-test.py | 18 | ||||
-rw-r--r-- | Tests/Server/tc_globalSettings.json | 10 |
4 files changed, 87 insertions, 3 deletions
diff --git a/Tests/Server/CMakeLists.txt b/Tests/Server/CMakeLists.txt index 8daf12a..03f5042 100644 --- a/Tests/Server/CMakeLists.txt +++ b/Tests/Server/CMakeLists.txt @@ -19,5 +19,6 @@ macro(do_test bsname file) endmacro() do_test("test_handshake" "tc_handshake.json") +do_test("test_globalSettings" "tc_globalSettings.json") add_executable(Server empty.cpp) diff --git a/Tests/Server/cmakelib.py b/Tests/Server/cmakelib.py index 0f98078..79cee80 100644 --- a/Tests/Server/cmakelib.py +++ b/Tests/Server/cmakelib.py @@ -106,6 +106,7 @@ def waitForReply(cmakeCommand, originalType, cookie): packet = waitForRawMessage(cmakeCommand) if packet['cookie'] != cookie or packet['type'] != 'reply' or packet['inReplyTo'] != originalType: sys.exit(1) + return packet def waitForError(cmakeCommand, originalType, cookie, message): packet = waitForRawMessage(cmakeCommand) @@ -117,10 +118,66 @@ def waitForProgress(cmakeCommand, originalType, cookie, current, message): if packet['cookie'] != cookie or packet['type'] != 'progress' or packet['inReplyTo'] != originalType or packet['progressCurrent'] != current or packet['progressMessage'] != message: sys.exit(1) -def handshake(cmakeCommand, major, minor): +def handshake(cmakeCommand, major, minor, source, build, generator, extraGenerator): version = { 'major': major } if minor >= 0: version['minor'] = minor - writePayload(cmakeCommand, { 'type': 'handshake', 'protocolVersion': version, 'cookie': 'TEST_HANDSHAKE' }) + writePayload(cmakeCommand, { 'type': 'handshake', 'protocolVersion': version, + 'cookie': 'TEST_HANDSHAKE', 'sourceDirectory': source, 'buildDirectory': build, + 'generator': generator, 'extraGenerator': extraGenerator }) waitForReply(cmakeCommand, 'handshake', 'TEST_HANDSHAKE') + +def validateGlobalSettings(cmakeCommand, cmakeCommandPath, data): + packet = waitForReply(cmakeCommand, 'globalSettings', '') + + capabilities = packet['capabilities'] + + # validate version: + cmakeoutput = subprocess.check_output([ cmakeCommandPath, "--version" ], universal_newlines=True) + cmakeVersion = cmakeoutput.splitlines()[0][14:] + + version = capabilities['version'] + versionString = version['string'] + vs = str(version['major']) + '.' + str(version['minor']) + '.' + str(version['patch']) + if (versionString != vs and not versionString.startswith(vs + '-')): + sys.exit(1) + if (versionString != cmakeVersion): + sys.exit(1) + + # validate generators: + generatorObjects = capabilities['generators'] + + cmakeoutput = subprocess.check_output([ cmakeCommandPath, "--help" ], universal_newlines=True) + index = cmakeoutput.index('\nGenerators\n\n') + cmakeGenerators = [] + for line in cmakeoutput[index + 12:].splitlines(): + if not line.startswith(' '): + continue + equalPos = line.find('=') + tmp = '' + if (equalPos > 0): + tmp = line[2:equalPos].strip() + else: + tmp = line.strip() + if (len(tmp) > 0) and (" - " not in tmp) and (tmp != 'KDevelop3'): + cmakeGenerators.append(tmp) + + generators = [] + for genObj in generatorObjects: + generators.append(genObj['name']) + + generators.sort() + cmakeGenerators.sort() + + if (generators != cmakeGenerators): + sys.exit(1) + + gen = packet['generator'] + if (gen != '' and not (gen in generators)): + sys.exit(1) + + for i in data: + print("Validating", i) + if (packet[i] != data[i]): + sys.exit(1) diff --git a/Tests/Server/server-test.py b/Tests/Server/server-test.py index e0a3b3b..d2bf92e 100644 --- a/Tests/Server/server-test.py +++ b/Tests/Server/server-test.py @@ -68,9 +68,25 @@ for obj in testData: if debug: print("Doing handshake:", json.dumps(data)) major = -1 minor = -1 + generator = 'Ninja' + extraGenerator = 'CodeBlocks' + sourceDirectory = sourceDir + buildDirectory = buildDir if 'major' in data: major = data['major'] if 'minor' in data: minor = data['minor'] - cmakelib.handshake(proc, major, minor) + if 'buildDirectory' in data: buildDirectory = data['buildDirectory'] + if 'sourceDirectory' in data: sourceDirectory = data['sourceDirectory'] + if 'generator' in data: generator = data['generator'] + if 'extraGenerator' in data: extraGenerator = data['extraGenerator'] + cmakelib.handshake(proc, major, minor, sourceDirectory, buildDirectory, + generator, extraGenerator) + elif 'validateGlobalSettings' in obj: + data = obj['validateGlobalSettings'] + if not 'buildDirectory' in data: data['buildDirectory'] = buildDir + if not 'sourceDirectory' in data: data['sourceDirectory'] = sourceDir + if not 'generator' in data: data['generator'] = 'Ninja' + if not 'extraGenerator' in data: data['extraGenerator'] = 'CodeBlocks' + cmakelib.validateGlobalSettings(proc, cmakeCommand, data) elif 'message' in obj: print("MESSAGE:", obj["message"]) else: diff --git a/Tests/Server/tc_globalSettings.json b/Tests/Server/tc_globalSettings.json new file mode 100644 index 0000000..70ef30d --- /dev/null +++ b/Tests/Server/tc_globalSettings.json @@ -0,0 +1,10 @@ +[ +{ "message": "Testing globalSettings" }, + +{ "handshake": {"major": 1} }, + +{ "send": {"type": "globalSettings"} }, +{ "validateGlobalSettings": { } }, + +{ "message": "Everything ok." } +] |