diff options
author | Brad King <brad.king@kitware.com> | 2022-01-10 22:11:55 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-01-10 22:12:03 (GMT) |
commit | 39eabc17c466d79c5e16cef236194d55a152a832 (patch) | |
tree | 8b2001fd5983976b28e820160e096b5229a18fe4 /Tests | |
parent | b9a40fd7ba0e9d0b63b9bb8ba57bd3c07c0c100c (diff) | |
parent | 26a5512c0f952333f089a08b0df84e3efa7fb063 (diff) | |
download | CMake-39eabc17c466d79c5e16cef236194d55a152a832.zip CMake-39eabc17c466d79c5e16cef236194d55a152a832.tar.gz CMake-39eabc17c466d79c5e16cef236194d55a152a832.tar.bz2 |
Merge topic 'cmake-presets-include'
26a5512c0f CMakePresets: Add include field
a239f23a98 Refactor: Generalize file graph in CMakePresets
84d440caac Refactor: Split JSON processing into configure, build, and test presets
fd6ea2f67f Refactor: Rename cmCMakePresetsFile to cmCMakePresetsGraph
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !6829
Diffstat (limited to 'Tests')
36 files changed, 232 insertions, 1 deletions
diff --git a/Tests/RunCMake/CMakePresets/Include-stdout.txt b/Tests/RunCMake/CMakePresets/Include-stdout.txt new file mode 100644 index 0000000..6ba1170 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/Include-stdout.txt @@ -0,0 +1,8 @@ +^Not searching for unused variables given on the command line\. +Available configure presets: + + "IncludeUser" + "IncludeUserCommon" + "Include" + "Subdir" + "IncludeCommon"$ diff --git a/Tests/RunCMake/CMakePresets/Include.json.in b/Tests/RunCMake/CMakePresets/Include.json.in new file mode 100644 index 0000000..3687d3c --- /dev/null +++ b/Tests/RunCMake/CMakePresets/Include.json.in @@ -0,0 +1,16 @@ +{ + "version": 4, + "include": [ + "subdir/CMakePresets.json", + "@RunCMake_TEST_SOURCE_DIR@/IncludeCommon.json" + ], + "configurePresets": [ + { + "name": "Include", + "inherits": [ + "IncludeCommon", + "Subdir" + ] + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/IncludeCommon.json.in b/Tests/RunCMake/CMakePresets/IncludeCommon.json.in new file mode 100644 index 0000000..eeae723 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeCommon.json.in @@ -0,0 +1,8 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "IncludeCommon" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/IncludeCycle-result.txt b/Tests/RunCMake/CMakePresets/IncludeCycle-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeCycle-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/IncludeCycle-stderr.txt b/Tests/RunCMake/CMakePresets/IncludeCycle-stderr.txt new file mode 100644 index 0000000..3343204 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeCycle-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/IncludeCycle: Cyclic include among preset files$ diff --git a/Tests/RunCMake/CMakePresets/IncludeCycle.json.in b/Tests/RunCMake/CMakePresets/IncludeCycle.json.in new file mode 100644 index 0000000..b35b6ff --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeCycle.json.in @@ -0,0 +1,11 @@ +{ + "version": 4, + "include": [ + "CMakeUserPresets.json" + ], + "configurePresets": [ + { + "name": "IncludeCycle" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/IncludeCycle3Files-result.txt b/Tests/RunCMake/CMakePresets/IncludeCycle3Files-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeCycle3Files-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/IncludeCycle3Files-stderr.txt b/Tests/RunCMake/CMakePresets/IncludeCycle3Files-stderr.txt new file mode 100644 index 0000000..35aea4c --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeCycle3Files-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/IncludeCycle3Files: Cyclic include among preset files$ diff --git a/Tests/RunCMake/CMakePresets/IncludeCycle3Files.json.in b/Tests/RunCMake/CMakePresets/IncludeCycle3Files.json.in new file mode 100644 index 0000000..8174ff0 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeCycle3Files.json.in @@ -0,0 +1,6 @@ +{ + "version": 4, + "include": [ + "IncludeCycle3Files2.json" + ] +} diff --git a/Tests/RunCMake/CMakePresets/IncludeCycle3Files2.json.in b/Tests/RunCMake/CMakePresets/IncludeCycle3Files2.json.in new file mode 100644 index 0000000..952e875 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeCycle3Files2.json.in @@ -0,0 +1,6 @@ +{ + "version": 4, + "include": [ + "IncludeCycle3Files3.json" + ] +} diff --git a/Tests/RunCMake/CMakePresets/IncludeCycle3Files3.json.in b/Tests/RunCMake/CMakePresets/IncludeCycle3Files3.json.in new file mode 100644 index 0000000..8dbf3ad --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeCycle3Files3.json.in @@ -0,0 +1,6 @@ +{ + "version": 4, + "include": [ + "CMakePresets.json" + ] +} diff --git a/Tests/RunCMake/CMakePresets/IncludeCycleUser.json.in b/Tests/RunCMake/CMakePresets/IncludeCycleUser.json.in new file mode 100644 index 0000000..cd2f236 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeCycleUser.json.in @@ -0,0 +1,3 @@ +{ + "version": 3 +} diff --git a/Tests/RunCMake/CMakePresets/IncludeNotFound-result.txt b/Tests/RunCMake/CMakePresets/IncludeNotFound-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeNotFound-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/IncludeNotFound-stderr.txt b/Tests/RunCMake/CMakePresets/IncludeNotFound-stderr.txt new file mode 100644 index 0000000..7ccabab --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeNotFound-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/IncludeNotFound: File not found$ diff --git a/Tests/RunCMake/CMakePresets/IncludeNotFound.json.in b/Tests/RunCMake/CMakePresets/IncludeNotFound.json.in new file mode 100644 index 0000000..a72b183 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeNotFound.json.in @@ -0,0 +1,11 @@ +{ + "version": 4, + "include": [ + "NotFound.json" + ], + "configurePresets": [ + { + "name": "IncludeNotFound" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/IncludeOutsideProject-result.txt b/Tests/RunCMake/CMakePresets/IncludeOutsideProject-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeOutsideProject-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/IncludeOutsideProject-stderr.txt b/Tests/RunCMake/CMakePresets/IncludeOutsideProject-stderr.txt new file mode 100644 index 0000000..2aa3f59 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeOutsideProject-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/IncludeOutsideProject: File included from outside project directory$ diff --git a/Tests/RunCMake/CMakePresets/IncludeOutsideProject.json.in b/Tests/RunCMake/CMakePresets/IncludeOutsideProject.json.in new file mode 100644 index 0000000..cf1928f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeOutsideProject.json.in @@ -0,0 +1,11 @@ +{ + "version": 4, + "include": [ + "IncludeOutsideProjectIntermediate.json" + ], + "configurePresets": [ + { + "name": "IncludeOutsideProject" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/IncludeOutsideProjectInclude.json b/Tests/RunCMake/CMakePresets/IncludeOutsideProjectInclude.json new file mode 100644 index 0000000..f13e55c --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeOutsideProjectInclude.json @@ -0,0 +1,3 @@ +{ + "version": 4 +} diff --git a/Tests/RunCMake/CMakePresets/IncludeOutsideProjectIntermediate.json.in b/Tests/RunCMake/CMakePresets/IncludeOutsideProjectIntermediate.json.in new file mode 100644 index 0000000..7c140c6 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeOutsideProjectIntermediate.json.in @@ -0,0 +1,6 @@ +{ + "version": 4, + "include": [ + "@RunCMake_SOURCE_DIR@/IncludeOutsideProjectInclude.json" + ] +} diff --git a/Tests/RunCMake/CMakePresets/IncludeOutsideProjectUser.json.in b/Tests/RunCMake/CMakePresets/IncludeOutsideProjectUser.json.in new file mode 100644 index 0000000..f4f540e --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeOutsideProjectUser.json.in @@ -0,0 +1,6 @@ +{ + "version": 4, + "include": [ + "IncludeOutsideProjectIntermediate.json" + ] +} diff --git a/Tests/RunCMake/CMakePresets/IncludeUser.json.in b/Tests/RunCMake/CMakePresets/IncludeUser.json.in new file mode 100644 index 0000000..46d23fd --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeUser.json.in @@ -0,0 +1,15 @@ +{ + "version": 4, + "include": [ + "IncludeUserCommon.json" + ], + "configurePresets": [ + { + "name": "IncludeUser", + "inherits": [ + "Include", + "IncludeUserCommon" + ] + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/IncludeUserCommon.json.in b/Tests/RunCMake/CMakePresets/IncludeUserCommon.json.in new file mode 100644 index 0000000..5a1bd36 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeUserCommon.json.in @@ -0,0 +1,8 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "IncludeUserCommon" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/IncludeUserOutsideProject.cmake b/Tests/RunCMake/CMakePresets/IncludeUserOutsideProject.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeUserOutsideProject.cmake diff --git a/Tests/RunCMake/CMakePresets/IncludeUserOutsideProjectUser.json.in b/Tests/RunCMake/CMakePresets/IncludeUserOutsideProjectUser.json.in new file mode 100644 index 0000000..5b5427a --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeUserOutsideProjectUser.json.in @@ -0,0 +1,11 @@ +{ + "version": 4, + "include": [ + "@RunCMake_SOURCE_DIR@/IncludeOutsideProjectInclude.json" + ], + "configurePresets": [ + { + "name": "IncludeUserOutsideProject" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/IncludeV3-result.txt b/Tests/RunCMake/CMakePresets/IncludeV3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeV3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/IncludeV3-stderr.txt b/Tests/RunCMake/CMakePresets/IncludeV3-stderr.txt new file mode 100644 index 0000000..1869b6d --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeV3-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/IncludeV3: File version must be 4 or higher for include support$ diff --git a/Tests/RunCMake/CMakePresets/IncludeV3.json.in b/Tests/RunCMake/CMakePresets/IncludeV3.json.in new file mode 100644 index 0000000..b28cad8 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeV3.json.in @@ -0,0 +1,4 @@ +{ + "version": 3, + "include": [] +} diff --git a/Tests/RunCMake/CMakePresets/IncludeV4V3-result.txt b/Tests/RunCMake/CMakePresets/IncludeV4V3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeV4V3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/IncludeV4V3-stderr.txt b/Tests/RunCMake/CMakePresets/IncludeV4V3-stderr.txt new file mode 100644 index 0000000..89e3e3d --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeV4V3-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/IncludeV4V3: File version must be 4 or higher for include support$ diff --git a/Tests/RunCMake/CMakePresets/IncludeV4V3.json.in b/Tests/RunCMake/CMakePresets/IncludeV4V3.json.in new file mode 100644 index 0000000..4afa319 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeV4V3.json.in @@ -0,0 +1,6 @@ +{ + "version": 4, + "include": [ + "IncludeV4V3Extra.json" + ] +} diff --git a/Tests/RunCMake/CMakePresets/IncludeV4V3Extra.json.in b/Tests/RunCMake/CMakePresets/IncludeV4V3Extra.json.in new file mode 100644 index 0000000..b28cad8 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeV4V3Extra.json.in @@ -0,0 +1,4 @@ +{ + "version": 3, + "include": [] +} diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake index c31a645..51e786e 100644 --- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake @@ -44,6 +44,20 @@ function(run_cmake_presets name) configure_file("${CMakeUserPresets_FILE}" "${RunCMake_TEST_SOURCE_DIR}/CMakeUserPresets.json" @ONLY) endif() + set(_CMakePresets_EXTRA_FILES_OUT) + set(_CMakePresets_EXTRA_FILES_SCHEMA_EXPECTED_RESULTS) + foreach(_extra_file IN LISTS CMakePresets_EXTRA_FILES) + cmake_path(RELATIVE_PATH _extra_file + BASE_DIRECTORY "${RunCMake_SOURCE_DIR}" + OUTPUT_VARIABLE _extra_file_relative + ) + string(REGEX REPLACE "\\.in$" "" _extra_file_out_relative "${_extra_file_relative}") + set(_extra_file_out "${RunCMake_TEST_SOURCE_DIR}/${_extra_file_out_relative}") + configure_file("${_extra_file}" "${_extra_file_out}") + list(APPEND _CMakePresets_EXTRA_FILES_OUT "${_extra_file_out}") + list(APPEND _CMakePresets_EXTRA_FILES_SCHEMA_EXPECTED_RESULTS 0) + endforeach() + set(_s_arg -S) if(CMakePresets_NO_S_ARG) set(_s_arg) @@ -319,6 +333,37 @@ run_cmake_presets(OptionalBinaryDirFieldNoS) unset(CMakePresets_SOURCE_ARG) unset(CMakePresets_NO_S_ARG) +# Test include field +set(CMakePresets_SCHEMA_EXPECTED_RESULT 1) +run_cmake_presets(IncludeV3) +set(CMakePresets_SCHEMA_EXPECTED_RESULT 0) +set(CMakePresets_EXTRA_FILES + "${RunCMake_SOURCE_DIR}/IncludeV4V3Extra.json.in" + ) +set(CMakePresets_EXTRA_FILES_SCHEMA_EXPECTED_RESULTS 1) +run_cmake_presets(IncludeV4V3) +unset(CMakePresets_EXTRA_FILES_SCHEMA_EXPECTED_RESULTS) +set(CMakePresets_EXTRA_FILES + "${RunCMake_SOURCE_DIR}/IncludeCommon.json.in" + "${RunCMake_SOURCE_DIR}/IncludeUserCommon.json.in" + "${RunCMake_SOURCE_DIR}/subdir/CMakePresets.json.in" + ) +run_cmake_presets(Include --list-presets) +unset(CMakePresets_EXTRA_FILES) +run_cmake_presets(IncludeNotFound) +run_cmake_presets(IncludeCycle) +set(CMakePresets_EXTRA_FILES + "${RunCMake_SOURCE_DIR}/IncludeCycle3Files2.json.in" + "${RunCMake_SOURCE_DIR}/IncludeCycle3Files3.json.in" + ) +run_cmake_presets(IncludeCycle3Files) +set(CMakePresets_EXTRA_FILES + "${RunCMake_SOURCE_DIR}/IncludeOutsideProjectIntermediate.json.in" + ) +run_cmake_presets(IncludeOutsideProject) +unset(CMakePresets_EXTRA_FILES) +run_cmake_presets(IncludeUserOutsideProject) + # Test the example from the documentation file(READ "${RunCMake_SOURCE_DIR}/../../../Help/manual/presets/example.json" _example) string(REPLACE "\"generator\": \"Ninja\"" "\"generator\": \"@RunCMake_GENERATOR@\"" _example "${_example}") diff --git a/Tests/RunCMake/CMakePresets/UserInheritance-stderr.txt b/Tests/RunCMake/CMakePresets/UserInheritance-stderr.txt index 213215a..5ad8b4b 100644 --- a/Tests/RunCMake/CMakePresets/UserInheritance-stderr.txt +++ b/Tests/RunCMake/CMakePresets/UserInheritance-stderr.txt @@ -1,2 +1,2 @@ ^CMake Error: Could not read presets from [^ -]*/Tests/RunCMake/CMakePresets/UserInheritance: Project preset inherits from user preset$ +]*/Tests/RunCMake/CMakePresets/UserInheritance: Inherited preset is unreachable from preset's file$ diff --git a/Tests/RunCMake/CMakePresets/check.cmake b/Tests/RunCMake/CMakePresets/check.cmake index bf43c7e..cef43f4 100644 --- a/Tests/RunCMake/CMakePresets/check.cmake +++ b/Tests/RunCMake/CMakePresets/check.cmake @@ -12,4 +12,11 @@ if(PYTHON_EXECUTABLE AND CMake_TEST_JSON_SCHEMA) if(EXISTS "${RunCMake_TEST_SOURCE_DIR}/CMakeUserPresets.json") validate_schema("${RunCMake_TEST_SOURCE_DIR}/CMakeUserPresets.json" "${CMakeUserPresets_SCHEMA_EXPECTED_RESULT}") endif() + + if(NOT CMakePresets_EXTRA_FILES_SCHEMA_EXPECTED_RESULTS) + set(CMakePresets_EXTRA_FILES_SCHEMA_EXPECTED_RESULTS "${_CMakePresets_EXTRA_FILES_SCHEMA_EXPECTED_RESULTS}") + endif() + foreach(_f _r IN ZIP_LISTS _CMakePresets_EXTRA_FILES_OUT CMakePresets_EXTRA_FILES_SCHEMA_EXPECTED_RESULTS) + validate_schema("${_f}" "${_r}") + endforeach() endif() diff --git a/Tests/RunCMake/CMakePresets/subdir/CMakePresets.json.in b/Tests/RunCMake/CMakePresets/subdir/CMakePresets.json.in new file mode 100644 index 0000000..deb9084 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/subdir/CMakePresets.json.in @@ -0,0 +1,12 @@ +{ + "version": 4, + "include": [ + "../IncludeCommon.json" + ], + "configurePresets": [ + { + "name": "Subdir", + "inherits": "IncludeCommon" + } + ] +} |