diff options
author | Brad King <brad.king@kitware.com> | 2016-09-29 12:09:45 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2016-09-29 12:09:45 (GMT) |
commit | 48cd0f74059f243d57d7032578a474452265b546 (patch) | |
tree | 354f9f2c842e79c3b3ffbc9ca7c1f7b7fe9d0c63 /Tests | |
parent | 26b30c58d0cd674a50f5b5c5df9ee7d6968c57d1 (diff) | |
parent | 71a505870c1f5a4fc89a8ad4e4dc3bb008a35118 (diff) | |
download | CMake-48cd0f74059f243d57d7032578a474452265b546.zip CMake-48cd0f74059f243d57d7032578a474452265b546.tar.gz CMake-48cd0f74059f243d57d7032578a474452265b546.tar.bz2 |
Merge topic 'cmake-server-commands'
71a50587 server-mode: Add project data for unit tests
7b1e60f2 server-mode: Report CMakeCache entries
84553a6e server-mode: Add command to retrieve build system files
ead71873 server-mode: Report information relevant for a codemodel
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/Server/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/Server/buildsystem1/CMakeLists.txt | 22 | ||||
-rw-r--r-- | Tests/Server/buildsystem1/foo.cpp | 5 | ||||
-rw-r--r-- | Tests/Server/buildsystem1/main.cpp | 5 | ||||
-rw-r--r-- | Tests/Server/buildsystem1/subdir/CMakeLists.txt | 5 | ||||
-rw-r--r-- | Tests/Server/buildsystem1/subdir/empty.cpp | 5 | ||||
-rw-r--r-- | Tests/Server/cmakelib.py | 20 | ||||
-rw-r--r-- | Tests/Server/server-test.py | 37 | ||||
-rw-r--r-- | Tests/Server/tc_buildsystem1.json | 27 |
9 files changed, 108 insertions, 20 deletions
diff --git a/Tests/Server/CMakeLists.txt b/Tests/Server/CMakeLists.txt index 03f5042..8913406 100644 --- a/Tests/Server/CMakeLists.txt +++ b/Tests/Server/CMakeLists.txt @@ -10,6 +10,7 @@ macro(do_test bsname file) "${CMAKE_SOURCE_DIR}/${file}" "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" + "${CMAKE_GENERATOR}" RESULT_VARIABLE test_result ) @@ -20,5 +21,6 @@ endmacro() do_test("test_handshake" "tc_handshake.json") do_test("test_globalSettings" "tc_globalSettings.json") +do_test("test_buildsystem1" "tc_buildsystem1.json") add_executable(Server empty.cpp) diff --git a/Tests/Server/buildsystem1/CMakeLists.txt b/Tests/Server/buildsystem1/CMakeLists.txt new file mode 100644 index 0000000..d690472 --- /dev/null +++ b/Tests/Server/buildsystem1/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.4) + +project(buildsystem2) + +set(var1 123) + +set(var2 345) + +add_executable(main main.cpp) + +add_executable(m_other main.cpp) + +add_library(foo foo.cpp) + +function(f1) +endfunction() + +set(var3 345) + +add_library(someImportedLib UNKNOWN IMPORTED) + +add_subdirectory(subdir) diff --git a/Tests/Server/buildsystem1/foo.cpp b/Tests/Server/buildsystem1/foo.cpp new file mode 100644 index 0000000..7f39d71 --- /dev/null +++ b/Tests/Server/buildsystem1/foo.cpp @@ -0,0 +1,5 @@ + +int foo() +{ + return 0; +} diff --git a/Tests/Server/buildsystem1/main.cpp b/Tests/Server/buildsystem1/main.cpp new file mode 100644 index 0000000..766b775 --- /dev/null +++ b/Tests/Server/buildsystem1/main.cpp @@ -0,0 +1,5 @@ + +int main() +{ + return 0; +} diff --git a/Tests/Server/buildsystem1/subdir/CMakeLists.txt b/Tests/Server/buildsystem1/subdir/CMakeLists.txt new file mode 100644 index 0000000..9157312 --- /dev/null +++ b/Tests/Server/buildsystem1/subdir/CMakeLists.txt @@ -0,0 +1,5 @@ +set(bar4 something) + +set(bar5 more) + +add_executable(ooo empty.cpp) diff --git a/Tests/Server/buildsystem1/subdir/empty.cpp b/Tests/Server/buildsystem1/subdir/empty.cpp new file mode 100644 index 0000000..7f39d71 --- /dev/null +++ b/Tests/Server/buildsystem1/subdir/empty.cpp @@ -0,0 +1,5 @@ + +int foo() +{ + return 0; +} diff --git a/Tests/Server/cmakelib.py b/Tests/Server/cmakelib.py index 8beaeef..94384eb 100644 --- a/Tests/Server/cmakelib.py +++ b/Tests/Server/cmakelib.py @@ -102,10 +102,20 @@ def waitForMessage(cmakeCommand, expected): sys.exit(-1) return packet -def waitForReply(cmakeCommand, originalType, cookie): - packet = waitForRawMessage(cmakeCommand) - if packet['cookie'] != cookie or packet['type'] != 'reply' or packet['inReplyTo'] != originalType: +def waitForReply(cmakeCommand, originalType, cookie, skipProgress): + gotResult = False + while True: + packet = waitForRawMessage(cmakeCommand) + t = packet['type'] + if packet['cookie'] != cookie or packet['inReplyTo'] != originalType: + sys.exit(1) + if t == 'message' or t == 'progress': + if skipProgress: + continue + if t == 'reply': + break sys.exit(1) + return packet def waitForError(cmakeCommand, originalType, cookie, message): @@ -126,10 +136,10 @@ def handshake(cmakeCommand, major, minor, source, build, generator, extraGenerat writePayload(cmakeCommand, { 'type': 'handshake', 'protocolVersion': version, 'cookie': 'TEST_HANDSHAKE', 'sourceDirectory': source, 'buildDirectory': build, 'generator': generator, 'extraGenerator': extraGenerator }) - waitForReply(cmakeCommand, 'handshake', 'TEST_HANDSHAKE') + waitForReply(cmakeCommand, 'handshake', 'TEST_HANDSHAKE', False) def validateGlobalSettings(cmakeCommand, cmakeCommandPath, data): - packet = waitForReply(cmakeCommand, 'globalSettings', '') + packet = waitForReply(cmakeCommand, 'globalSettings', '', False) capabilities = packet['capabilities'] diff --git a/Tests/Server/server-test.py b/Tests/Server/server-test.py index d2bf92e..72f82ba 100644 --- a/Tests/Server/server-test.py +++ b/Tests/Server/server-test.py @@ -1,24 +1,25 @@ -import sys, cmakelib, json +import sys, cmakelib, json, os, shutil debug = True cmakeCommand = sys.argv[1] testFile = sys.argv[2] sourceDir = sys.argv[3] -buildDir = sys.argv[4] +buildDir = sys.argv[4] + "/" + os.path.splitext(os.path.basename(testFile))[0] +cmakeGenerator = sys.argv[5] -print("SourceDir: ", sourceDir, " -- BuildDir: ", buildDir) +print("Test:", testFile, + "\n-- SourceDir:", sourceDir, + "\n-- BuildDir:", buildDir, + "\n-- Generator:", cmakeGenerator) + +if os.path.exists(buildDir): + shutil.rmtree(buildDir) proc = cmakelib.initProc(cmakeCommand) with open(testFile) as f: - testText = f.read() - testText = testText.replace('%BUILDDIR%', buildDir) - testText = testText.replace('%SOURCEDIR%', sourceDir) - testData = json.loads(testText) - -buildDir = sys.argv[3] -sourceDir = sys.argv[4] + testData = json.loads(f.read()) for obj in testData: if 'sendRaw' in obj: @@ -38,9 +39,11 @@ for obj in testData: if debug: print("Waiting for reply:", json.dumps(data)) originalType = "" cookie = "" + skipProgress = False; if 'cookie' in data: cookie = data['cookie'] if 'type' in data: originalType = data['type'] - cmakelib.waitForReply(proc, originalType, cookie) + if 'skipProgress' in data: skipProgress = data['skipProgress'] + cmakelib.waitForReply(proc, originalType, cookie, skipProgress) elif 'error' in obj: data = obj['error'] if debug: print("Waiting for error:", json.dumps(data)) @@ -68,8 +71,8 @@ for obj in testData: if debug: print("Doing handshake:", json.dumps(data)) major = -1 minor = -1 - generator = 'Ninja' - extraGenerator = 'CodeBlocks' + generator = cmakeGenerator + extraGenerator = '' sourceDirectory = sourceDir buildDirectory = buildDir if 'major' in data: major = data['major'] @@ -78,14 +81,18 @@ for obj in testData: if 'sourceDirectory' in data: sourceDirectory = data['sourceDirectory'] if 'generator' in data: generator = data['generator'] if 'extraGenerator' in data: extraGenerator = data['extraGenerator'] + if not os.path.isabs(buildDirectory): + buildDirectory = buildDir + "/" + buildDirectory + if not os.path.isabs(sourceDirectory): + sourceDirectory = sourceDir + "/" + sourceDirectory 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' + if not 'generator' in data: data['generator'] = cmakeGenerator + if not 'extraGenerator' in data: data['extraGenerator'] = '' cmakelib.validateGlobalSettings(proc, cmakeCommand, data) elif 'message' in obj: print("MESSAGE:", obj["message"]) diff --git a/Tests/Server/tc_buildsystem1.json b/Tests/Server/tc_buildsystem1.json new file mode 100644 index 0000000..08831b7 --- /dev/null +++ b/Tests/Server/tc_buildsystem1.json @@ -0,0 +1,27 @@ +[ +{ "message": "Testing globalSettings" }, + +{ "handshake": {"major": 1, "sourceDirectory":"buildsystem1","buildDirectory":"buildsystem1"} }, + +{ "message": "Configure:" }, +{ "send": { "type": "configure", "cookie":"CONFIG" } }, +{ "reply": { "type": "configure", "cookie":"CONFIG", "skipProgress":true } }, + +{ "message": "Compute:" }, +{ "send": { "type": "compute", "cookie":"COMPUTE" } }, +{ "reply": { "type": "compute", "cookie":"COMPUTE", "skipProgress":true } }, + +{ "message": "Codemodel:" }, +{ "send": { "type": "codemodel", "cookie":"CODEMODEL" } }, +{ "reply": { "type": "codemodel", "cookie":"CODEMODEL" } }, + +{ "message": "CMake Inputs:"}, +{ "send": { "type": "cmakeInputs", "cookie":"INPUTS" } }, +{ "reply": { "type": "cmakeInputs", "cookie":"INPUTS" } }, + +{ "message": "Cache:"}, +{ "send": { "type": "cache", "cookie":"CACHE" } }, +{ "reply": { "type": "cache", "cookie":"CACHE" } }, + +{ "message": "Everything ok." } +] |