diff options
author | Brad King <brad.king@kitware.com> | 2016-09-27 12:22:50 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2016-09-27 12:22:50 (GMT) |
commit | e8ff565d94baf45df145dfef46e8cd40aedc08ff (patch) | |
tree | e5e59e4a8c0396f6980c951391cbb0eee2e72111 /Tests | |
parent | e56eca3f6838d715fa10623a5ca538b3c9476493 (diff) | |
parent | 890432672bc9fe91365e5e5305285ab193e9060a (diff) | |
download | CMake-e8ff565d94baf45df145dfef46e8cd40aedc08ff.zip CMake-e8ff565d94baf45df145dfef46e8cd40aedc08ff.tar.gz CMake-e8ff565d94baf45df145dfef46e8cd40aedc08ff.tar.bz2 |
Merge topic 'cmake-server-basic-commands'
89043267 server-mode: Add command to compute the build system
0a8ad670 server-mode: Add a configure command
544f65f4 server-mode: Set global configuration of cmake via a command
82104cc7 server-mode: Query global configuration of cmake via a command
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/Server/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/Server/cmakelib.py | 66 | ||||
-rw-r--r-- | Tests/Server/server-test.py | 18 | ||||
-rw-r--r-- | Tests/Server/tc_globalSettings.json | 140 |
4 files changed, 222 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..8beaeef 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,71 @@ 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 + if line.startswith(' '): + continue + equalPos = line.find('=') + tmp = '' + if (equalPos > 0): + tmp = line[2:equalPos].strip() + else: + tmp = line.strip() + if tmp.endswith(" [arch]"): + tmp = tmp[0:len(tmp) - 7] + 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() + + for gen in cmakeGenerators: + if (not gen in generators): + 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..d72fb41 --- /dev/null +++ b/Tests/Server/tc_globalSettings.json @@ -0,0 +1,140 @@ +[ +{ "message": "Testing globalSettings" }, + +{ "handshake": {"major": 1} }, + +{ "send": { "type": "globalSettings"} }, +{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } }, + + + +{ "message": "Change settings:" }, + +{ "send": { "type": "setGlobalSettings", "warnUnused": true } }, +{ "reply": { "type": "setGlobalSettings" } }, + +{ "send": { "type": "globalSettings"} }, +{ "validateGlobalSettings": { "warnUnused": true, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } }, + +{ "send": { "type": "setGlobalSettings", "warnUnused": false } }, +{ "reply": { "type": "setGlobalSettings" } }, + +{ "send": { "type": "globalSettings"} }, +{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } }, + +{ "send": { "type": "setGlobalSettings", "debugOutput": true } }, +{ "reply": { "type": "setGlobalSettings" } }, + +{ "send": { "type": "globalSettings"} }, +{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": true, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } }, + +{ "send": { "type": "setGlobalSettings", "debugOutput": false } }, +{ "reply": { "type": "setGlobalSettings" } }, + +{ "send": { "type": "globalSettings"} }, +{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } }, + +{ "send": { "type": "setGlobalSettings", "warnUninitialized": true } }, +{ "reply": { "type": "setGlobalSettings" } }, + +{ "send": { "type": "globalSettings"} }, +{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": true, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } }, + +{ "send": { "type": "setGlobalSettings", "warnUninitialized": false } }, +{ "reply": { "type": "setGlobalSettings" } }, + +{ "send": { "type": "globalSettings"} }, +{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } }, + +{ "send": { "type": "setGlobalSettings", "traceExpand": true } }, +{ "reply": { "type": "setGlobalSettings" } }, + +{ "send": { "type": "globalSettings"} }, +{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": true, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } }, + +{ "send": { "type": "setGlobalSettings", "traceExpand": false } }, +{ "reply": { "type": "setGlobalSettings" } }, + +{ "send": { "type": "globalSettings"} }, +{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } }, + + + +{ "send": { "type": "setGlobalSettings", "trace": true } }, +{ "reply": { "type": "setGlobalSettings" } }, + +{ "send": { "type": "globalSettings"} }, +{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": true, "warnUnusedCli": true, "checkSystemVars": false } }, + +{ "send": { "type": "setGlobalSettings", "trace": false } }, +{ "reply": { "type": "setGlobalSettings" } }, + +{ "send": { "type": "globalSettings"} }, +{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } }, + +{ "send": { "type": "setGlobalSettings", "warnUnusedCli": false } }, +{ "reply": { "type": "setGlobalSettings" } }, + +{ "send": { "type": "globalSettings"} }, +{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": false, "checkSystemVars": false } }, + +{ "send": { "type": "setGlobalSettings", "warnUnusedCli": true } }, +{ "reply": { "type": "setGlobalSettings" } }, + +{ "send": { "type": "globalSettings"} }, +{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } }, + +{ "send": { "type": "setGlobalSettings", "checkSystemVars": true } }, +{ "reply": { "type": "setGlobalSettings" } }, + +{ "send": { "type": "globalSettings"} }, +{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": true } }, + +{ "send": { "type": "setGlobalSettings", "checkSystemVars": false } }, +{ "reply": { "type": "setGlobalSettings" } }, + +{ "send": { "type": "globalSettings"} }, +{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } }, + +{ "send": { "type": "setGlobalSettings", "warnUnused": true, "debugOutput": true, "warnUninitialized": true, "traceExpand": true, "trace": true, "warnUnusedCli": false, "checkSystemVars": true } }, +{ "reply": { "type": "setGlobalSettings" } }, + +{ "send": { "type": "globalSettings"} }, +{ "validateGlobalSettings": { "warnUnused": true, "debugOutput": true, "warnUninitialized": true, "traceExpand": true, "trace": true, "warnUnusedCli": false, "checkSystemVars": true } }, + +{ "message": "Ignore unknown/readonly" }, + +{ "send": { "type": "setGlobalSettings", "unknownKey": "unknownValue", "extraGenerator": "XXX", "generator": "YYY", "sourceDirectory": "/tmp/source", "buildDirectory": "/tmp/build" } }, +{ "reply": { "type": "setGlobalSettings" } }, + +{ "send": { "type": "globalSettings"} }, +{ "validateGlobalSettings": { "warnUnused": true, "debugOutput": true, "warnUninitialized": true, "traceExpand": true, "trace": true, "warnUnusedCli": false, "checkSystemVars": true } }, + +{ "message": "Error paths:" }, + +{ "send": { "type": "setGlobalSettings", "debugOutput": true, "warnUnused": 1 } }, +{ "error": { "type": "setGlobalSettings", "message": "\"warnUnused\" must be unset or a bool value." } }, + +{ "send": { "type": "setGlobalSettings", "warnUnused": true, "debugOutput": 1 } }, +{ "error": { "type": "setGlobalSettings", "message": "\"debugOutput\" must be unset or a bool value." } }, + +{ "send": { "type": "setGlobalSettings", "warnUninitialized": 1, "warnUnused": true, "debugOutput": true } }, +{ "error": { "type": "setGlobalSettings", "message": "\"warnUninitialized\" must be unset or a bool value." } }, + +{ "send": { "type": "setGlobalSettings", "warnUnused": true, "debugOutput": true, "traceExpand": 1 } }, +{ "error": { "type": "setGlobalSettings", "message": "\"traceExpand\" must be unset or a bool value." } }, + +{ "send": { "type": "setGlobalSettings", "debugOutput": true, "trace": 1, "warnUnused": true } }, +{ "error": { "type": "setGlobalSettings", "message": "\"trace\" must be unset or a bool value." } }, + +{ "send": { "type": "setGlobalSettings", "warnUnused": true, "debugOutput": true, "warnUnusedCli": 1.0 } }, +{ "error": { "type": "setGlobalSettings", "message": "\"warnUnusedCli\" must be unset or a bool value." } }, + +{ "send": { "type": "setGlobalSettings", "warnUnused": true, "debugOutput": true, "checkSystemVars": "some string" } }, +{ "error": { "type": "setGlobalSettings", "message": "\"checkSystemVars\" must be unset or a bool value." } }, + +{ "send": { "type": "globalSettings"} }, +{ "validateGlobalSettings": { "warnUnused": true, "debugOutput": true, "warnUninitialized": true, "traceExpand": true, "trace": true, "warnUnusedCli": false, "checkSystemVars": true } }, + +{ "message": "Everything ok." } +] |