diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2018-11-12 20:23:17 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2018-12-12 18:02:31 (GMT) |
commit | 42f0125ceb6c34ce5a67e9954d1831b2aeb263ba (patch) | |
tree | d4cdeb9e17dae7acb1ae706f8d98786eac317c61 | |
parent | 6615408193aa542833ef34c902a35831bd85d25a (diff) | |
download | CMake-42f0125ceb6c34ce5a67e9954d1831b2aeb263ba.zip CMake-42f0125ceb6c34ce5a67e9954d1831b2aeb263ba.tar.gz CMake-42f0125ceb6c34ce5a67e9954d1831b2aeb263ba.tar.bz2 |
fileapi: Add test for cmakeFiles v1
-rw-r--r-- | Tests/RunCMake/FileAPI/cmakeFiles-v1-check.py | 81 | ||||
-rw-r--r-- | Tests/RunCMake/FileAPI/cmakeFiles-v1.cmake | 8 | ||||
-rw-r--r-- | Tests/RunCMake/FileAPI/dir/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/FileAPI/dir/dir/CMakeLists.txt | 0 | ||||
-rw-r--r-- | Tests/RunCMake/FileAPI/dir/dirtest.cmake | 0 | ||||
-rw-r--r-- | Tests/RunCMake/FileAPIDummyFile.cmake | 0 |
6 files changed, 89 insertions, 1 deletions
diff --git a/Tests/RunCMake/FileAPI/cmakeFiles-v1-check.py b/Tests/RunCMake/FileAPI/cmakeFiles-v1-check.py index 25dabf8..49dfe87 100644 --- a/Tests/RunCMake/FileAPI/cmakeFiles-v1-check.py +++ b/Tests/RunCMake/FileAPI/cmakeFiles-v1-check.py @@ -5,10 +5,89 @@ def check_objects(o): assert len(o) == 1 check_index_object(o[0], "cmakeFiles", 1, 0, check_object_cmakeFiles) +def check_input(actual, expected): + assert is_dict(actual) + expected_keys = ["path"] + + if expected["isGenerated"] is not None: + expected_keys.append("isGenerated") + assert is_bool(actual["isGenerated"], expected["isGenerated"]) + + if expected["isExternal"] is not None: + expected_keys.append("isExternal") + assert is_bool(actual["isExternal"], expected["isExternal"]) + + if expected["isCMake"] is not None: + expected_keys.append("isCMake") + assert is_bool(actual["isCMake"], expected["isCMake"]) + + assert sorted(actual.keys()) == sorted(expected_keys) + def check_object_cmakeFiles(o): assert sorted(o.keys()) == ["inputs", "kind", "paths", "version"] # The "kind" and "version" members are handled by check_index_object. - # FIXME: Check "paths" and "inputs" members. + assert is_dict(o["paths"]) + assert sorted(o["paths"].keys()) == ["build", "source"] + assert matches(o["paths"]["build"], "^.*/Tests/RunCMake/FileAPI/cmakeFiles-v1-build$") + assert matches(o["paths"]["source"], "^.*/Tests/RunCMake/FileAPI$") + + expected = [ + { + "path": "^CMakeLists\\.txt$", + "isGenerated": None, + "isExternal": None, + "isCMake": None, + }, + { + "path": "^cmakeFiles-v1\\.cmake$", + "isGenerated": None, + "isExternal": None, + "isCMake": None, + }, + { + "path": "^dir/CMakeLists\\.txt$", + "isGenerated": None, + "isExternal": None, + "isCMake": None, + }, + { + "path": "^dir/dir/CMakeLists\\.txt$", + "isGenerated": None, + "isExternal": None, + "isCMake": None, + }, + { + "path": "^dir/dirtest\\.cmake$", + "isGenerated": None, + "isExternal": None, + "isCMake": None, + }, + { + "path": "^.*/Tests/RunCMake/FileAPIDummyFile\\.cmake$", + "isGenerated": None, + "isExternal": True, + "isCMake": None, + }, + { + "path": "^.*/Tests/RunCMake/FileAPI/cmakeFiles-v1-build/generated\\.cmake", + "isGenerated": True, + "isExternal": None, + "isCMake": None, + }, + { + "path": "^.*/Modules/CMakeParseArguments\\.cmake$", + "isGenerated": None, + "isExternal": True, + "isCMake": True, + }, + ] + + inSource = os.path.dirname(o["paths"]["build"]) == o["paths"]["source"] + if inSource: + for e in expected: + e["path"] = e["path"].replace("^.*/Tests/RunCMake/FileAPI/", "^", 1) + + check_list_match(lambda a, e: matches(a["path"], e["path"]), o["inputs"], expected, check=check_input, allow_extra=True) assert is_dict(index) assert sorted(index.keys()) == ["cmake", "objects", "reply"] diff --git a/Tests/RunCMake/FileAPI/cmakeFiles-v1.cmake b/Tests/RunCMake/FileAPI/cmakeFiles-v1.cmake index e69de29..4d4d757 100644 --- a/Tests/RunCMake/FileAPI/cmakeFiles-v1.cmake +++ b/Tests/RunCMake/FileAPI/cmakeFiles-v1.cmake @@ -0,0 +1,8 @@ +include("${CMAKE_CURRENT_LIST_DIR}/dir/dirtest.cmake") +include(CMakeParseArguments) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/generated.cmake" "") +include("${CMAKE_CURRENT_BINARY_DIR}/generated.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/../FileAPIDummyFile.cmake") + +add_subdirectory(dir) diff --git a/Tests/RunCMake/FileAPI/dir/CMakeLists.txt b/Tests/RunCMake/FileAPI/dir/CMakeLists.txt new file mode 100644 index 0000000..780445d --- /dev/null +++ b/Tests/RunCMake/FileAPI/dir/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(dir) diff --git a/Tests/RunCMake/FileAPI/dir/dir/CMakeLists.txt b/Tests/RunCMake/FileAPI/dir/dir/CMakeLists.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FileAPI/dir/dir/CMakeLists.txt diff --git a/Tests/RunCMake/FileAPI/dir/dirtest.cmake b/Tests/RunCMake/FileAPI/dir/dirtest.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FileAPI/dir/dirtest.cmake diff --git a/Tests/RunCMake/FileAPIDummyFile.cmake b/Tests/RunCMake/FileAPIDummyFile.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FileAPIDummyFile.cmake |