summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorSam Freed <safreed@microsoft.com>2021-01-13 22:48:58 (GMT)
committerBrad King <brad.king@kitware.com>2021-02-04 16:39:19 (GMT)
commit74a86566f0f27e849acdc1e0648b3ef223b13369 (patch)
tree0325dd071b7a8697cecd78826e6766766a14215c /Tests/RunCMake
parent56751c83aa1b9de7f3c785b17922eb9af6bc9e4a (diff)
downloadCMake-74a86566f0f27e849acdc1e0648b3ef223b13369.zip
CMake-74a86566f0f27e849acdc1e0648b3ef223b13369.tar.gz
CMake-74a86566f0f27e849acdc1e0648b3ef223b13369.tar.bz2
Tests: Add build preset tests
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/CMakeLists.txt.in3
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/Good-build-build-other-check.cmake5
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/Good-build-macros-check.cmake14
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/Good-build-noEnvironment-check.cmake6
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/Good-build-withEnvironment-check.cmake8
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/Good.cmake3
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/Good.json.in78
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/Invalid-build-badConfigurePreset-result.txt1
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/Invalid-build-badConfigurePreset-stderr.txt2
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/Invalid-build-hidden-result.txt1
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/Invalid-build-hidden-stderr.txt2
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/Invalid-build-vendorMacro-result.txt1
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/Invalid-build-vendorMacro-stderr.txt1
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/Invalid.cmake0
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/Invalid.json.in27
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/ListPresets-build-x-stdout.txt5
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/ListPresets.cmake0
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/ListPresets.json.in31
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/NoConfigurePreset-build-noConfigurePreset-result.txt1
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/NoConfigurePreset-build-noConfigurePreset-stderr.txt2
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/NoConfigurePreset.cmake0
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/NoConfigurePreset.json.in15
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/PresetsUnsupported-build-x-result.txt1
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/PresetsUnsupported-build-x-stderr.txt2
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/PresetsUnsupported.json.in7
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake67
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/TestVariable.cmake14
-rw-r--r--Tests/RunCMake/CMakePresetsBuild/check.cmake3
29 files changed, 301 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index bd08dd9..09890c0 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -799,6 +799,7 @@ add_RunCMake_test(PrecompileHeaders -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}
add_RunCMake_test("UnityBuild")
add_RunCMake_test(CMakePresets -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -DCMake_TEST_JSON_SCHEMA=${CMake_TEST_JSON_SCHEMA})
+add_RunCMake_test(CMakePresetsBuild -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -DCMake_TEST_JSON_SCHEMA=${CMake_TEST_JSON_SCHEMA})
if(${CMAKE_GENERATOR} MATCHES "Make|Ninja")
add_RunCMake_test(TransformDepfile)
diff --git a/Tests/RunCMake/CMakePresetsBuild/CMakeLists.txt.in b/Tests/RunCMake/CMakePresetsBuild/CMakeLists.txt.in
new file mode 100644
index 0000000..129184a
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/CMakeLists.txt.in
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.19)
+project("@CASE_NAME@" NONE)
+include("@CASE_SOURCE_DIR@/@CASE_NAME@.cmake")
diff --git a/Tests/RunCMake/CMakePresetsBuild/Good-build-build-other-check.cmake b/Tests/RunCMake/CMakePresetsBuild/Good-build-build-other-check.cmake
new file mode 100644
index 0000000..b2699db
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/Good-build-build-other-check.cmake
@@ -0,0 +1,5 @@
+include("${RunCMake_SOURCE_DIR}/TestVariable.cmake")
+
+test_environment_variable("TEST_ENV_" "other")
+
+include("${RunCMake_SOURCE_DIR}/check.cmake")
diff --git a/Tests/RunCMake/CMakePresetsBuild/Good-build-macros-check.cmake b/Tests/RunCMake/CMakePresetsBuild/Good-build-macros-check.cmake
new file mode 100644
index 0000000..7801c3d
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/Good-build-macros-check.cmake
@@ -0,0 +1,14 @@
+include("${RunCMake_SOURCE_DIR}/TestVariable.cmake")
+
+if(RunCMake_GENERATOR STREQUAL "NMake Makefiles JOM")
+ # JOM removes the '$' and content following it.
+else()
+ test_environment_variable("TEST_DOLLAR" "x\\$x")
+endif()
+test_environment_variable("TEST_GENERATOR" "${RunCMake_GENERATOR}")
+test_environment_variable("TEST_PRESET_NAME" "xmacrosx")
+test_environment_variable("TEST_SOURCE_DIR_" "x[^\n]*[/\\\\]Tests[/\\\\]RunCMake[/\\\\]CMakePresetsBuild[/\\\\]Goodx")
+test_environment_variable("TEST_SOURCE_DIR_NAME" "xGoodx")
+test_environment_variable("TEST_SOURCE_PARENT_DIR" "x[^\n]*[/\\\\]Tests[/\\\\]RunCMake[/\\\\]CMakePresetsBuildx")
+
+include("${RunCMake_SOURCE_DIR}/check.cmake")
diff --git a/Tests/RunCMake/CMakePresetsBuild/Good-build-noEnvironment-check.cmake b/Tests/RunCMake/CMakePresetsBuild/Good-build-noEnvironment-check.cmake
new file mode 100644
index 0000000..94a54ca
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/Good-build-noEnvironment-check.cmake
@@ -0,0 +1,6 @@
+string(FIND "${actual_stdout}" "TEST_ENV_" TEST_ENV_POS)
+if (NOT TEST_ENV_POS EQUAL -1)
+ message(FATAL_ERROR "Found TEST_ENV_ in environment")
+endif()
+
+include("${RunCMake_SOURCE_DIR}/check.cmake")
diff --git a/Tests/RunCMake/CMakePresetsBuild/Good-build-withEnvironment-check.cmake b/Tests/RunCMake/CMakePresetsBuild/Good-build-withEnvironment-check.cmake
new file mode 100644
index 0000000..9c6b5c2
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/Good-build-withEnvironment-check.cmake
@@ -0,0 +1,8 @@
+include("${RunCMake_SOURCE_DIR}/TestVariable.cmake")
+
+test_environment_variable("TEST_ENV_" "Environment variable")
+test_environment_variable("TEST_ENV_OVERRIDE_" "Overridden")
+test_environment_variable("TEST_ENV_OVERRIDE_REF" "xOverriddenx")
+test_environment_variable("TEST_ENV_REF" "xEnvironment variablex")
+
+include("${RunCMake_SOURCE_DIR}/check.cmake")
diff --git a/Tests/RunCMake/CMakePresetsBuild/Good.cmake b/Tests/RunCMake/CMakePresetsBuild/Good.cmake
new file mode 100644
index 0000000..491d367
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/Good.cmake
@@ -0,0 +1,3 @@
+add_custom_target(good ALL)
+add_custom_command(TARGET good PRE_BUILD
+ COMMAND ${CMAKE_COMMAND} -E environment)
diff --git a/Tests/RunCMake/CMakePresetsBuild/Good.json.in b/Tests/RunCMake/CMakePresetsBuild/Good.json.in
new file mode 100644
index 0000000..fd43c4e
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/Good.json.in
@@ -0,0 +1,78 @@
+{
+ "version": 2,
+ "configurePresets": [
+ {
+ "name": "default",
+ "generator": "@RunCMake_GENERATOR@",
+ "binaryDir": "${sourceDir}/build/${presetName}",
+ "environment": {
+ "TEST_ENV_": "Environment variable",
+ "TEST_ENV_OVERRIDE_": "Environment variable",
+ "TEST_ENV_OVERRIDE_REF": "x$env{TEST_ENV_OVERRIDE_}x"
+ }
+ },
+ {
+ "name": "other",
+ "inherits": "default",
+ "environment": {
+ "TEST_ENV_": "other"
+ }
+ }
+ ],
+ "buildPresets": [
+ {
+ "name": "build-default",
+ "hidden": true,
+ "inherits": [],
+ "configurePreset": "default",
+ "vendor": {},
+ "displayName": "",
+ "description": "",
+ "inheritConfigureEnvironment": true,
+ "environment": {},
+ "jobs": 0,
+ "targets": [],
+ "configuration": "",
+ "verbose": true,
+ "nativeToolOptions": []
+ },
+ {
+ "name": "build-other",
+ "configurePreset": "other"
+ },
+ {
+ "name": "withEnvironment",
+ "inherits": "build-default",
+ "environment": {
+ "TEST_ENV_OVERRIDE_": "Overridden",
+ "TEST_ENV_REF": "x$env{TEST_ENV_}x",
+ "TEST_ENV_OVERRIDE_REF": "x$env{TEST_ENV_OVERRIDE_}x"
+ }
+ },
+ {
+ "name": "noEnvironment",
+ "inherits": "build-default",
+ "inheritConfigureEnvironment": false
+ },
+ {
+ "name": "macros",
+ "inherits": "build-default",
+ "inheritConfigureEnvironment": false,
+ "environment": {
+ "TEST_SOURCE_DIR_": "x${sourceDir}x",
+ "TEST_SOURCE_PARENT_DIR": "x${sourceParentDir}x",
+ "TEST_SOURCE_DIR_NAME": "x${sourceDirName}x",
+ "TEST_PRESET_NAME": "x${presetName}x",
+ "TEST_GENERATOR": "x${generator}x",
+ "TEST_DOLLAR": "x${dollar}x"
+ }
+ },
+ {
+ "name": "vendorObject",
+ "configurePreset": "default",
+ "vendor": {
+ "example.com": "value"
+ }
+ }
+ ]
+}
diff --git a/Tests/RunCMake/CMakePresetsBuild/Invalid-build-badConfigurePreset-result.txt b/Tests/RunCMake/CMakePresetsBuild/Invalid-build-badConfigurePreset-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/Invalid-build-badConfigurePreset-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CMakePresetsBuild/Invalid-build-badConfigurePreset-stderr.txt b/Tests/RunCMake/CMakePresetsBuild/Invalid-build-badConfigurePreset-stderr.txt
new file mode 100644
index 0000000..7c3255d
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/Invalid-build-badConfigurePreset-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error: No such configure preset in [^
+]*/Tests/RunCMake/CMakePresetsBuild/Invalid: "dne"
diff --git a/Tests/RunCMake/CMakePresetsBuild/Invalid-build-hidden-result.txt b/Tests/RunCMake/CMakePresetsBuild/Invalid-build-hidden-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/Invalid-build-hidden-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CMakePresetsBuild/Invalid-build-hidden-stderr.txt b/Tests/RunCMake/CMakePresetsBuild/Invalid-build-hidden-stderr.txt
new file mode 100644
index 0000000..f10c7b8
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/Invalid-build-hidden-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error: Cannot use hidden build preset in [^
+]*/Tests/RunCMake/CMakePresetsBuild/Invalid: "hidden"
diff --git a/Tests/RunCMake/CMakePresetsBuild/Invalid-build-vendorMacro-result.txt b/Tests/RunCMake/CMakePresetsBuild/Invalid-build-vendorMacro-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/Invalid-build-vendorMacro-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CMakePresetsBuild/Invalid-build-vendorMacro-stderr.txt b/Tests/RunCMake/CMakePresetsBuild/Invalid-build-vendorMacro-stderr.txt
new file mode 100644
index 0000000..a3b951f
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/Invalid-build-vendorMacro-stderr.txt
@@ -0,0 +1 @@
+CMake Error: Could not evaluate build preset "vendorMacro": Invalid macro expansion
diff --git a/Tests/RunCMake/CMakePresetsBuild/Invalid.cmake b/Tests/RunCMake/CMakePresetsBuild/Invalid.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/Invalid.cmake
diff --git a/Tests/RunCMake/CMakePresetsBuild/Invalid.json.in b/Tests/RunCMake/CMakePresetsBuild/Invalid.json.in
new file mode 100644
index 0000000..cf56cef
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/Invalid.json.in
@@ -0,0 +1,27 @@
+{
+ "version": 2,
+ "configurePresets": [
+ {
+ "name": "default",
+ "generator": "@RunCMake_GENERATOR@",
+ "binaryDir": "${sourceDir}/build/${presetName}"
+ }
+ ],
+ "buildPresets": [
+ {
+ "name": "hidden",
+ "hidden": true
+ },
+ {
+ "name": "vendorMacro",
+ "configurePreset": "default",
+ "environment": {
+ "TEST": "$vendor{bad.TEST}"
+ }
+ },
+ {
+ "name": "badConfigurePreset",
+ "configurePreset": "dne"
+ }
+ ]
+}
diff --git a/Tests/RunCMake/CMakePresetsBuild/ListPresets-build-x-stdout.txt b/Tests/RunCMake/CMakePresetsBuild/ListPresets-build-x-stdout.txt
new file mode 100644
index 0000000..4d30707
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/ListPresets-build-x-stdout.txt
@@ -0,0 +1,5 @@
+Available build presets:
+
+ "build-default" - build-default displayName
+ "empty"
+ "display" - display displayName
diff --git a/Tests/RunCMake/CMakePresetsBuild/ListPresets.cmake b/Tests/RunCMake/CMakePresetsBuild/ListPresets.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/ListPresets.cmake
diff --git a/Tests/RunCMake/CMakePresetsBuild/ListPresets.json.in b/Tests/RunCMake/CMakePresetsBuild/ListPresets.json.in
new file mode 100644
index 0000000..3f5e02c
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/ListPresets.json.in
@@ -0,0 +1,31 @@
+{
+ "version": 2,
+ "configurePresets": [
+ {
+ "name": "default",
+ "generator": "@RunCMake_GENERATOR@",
+ "binaryDir": "${sourceDir}/build/${presetName}"
+ }
+ ],
+ "buildPresets": [
+ {
+ "name": "build-default",
+ "configurePreset": "default",
+ "displayName": "build-default displayName",
+ "description": "build-default description"
+ },
+ {
+ "name": "empty",
+ "inherits": "build-default"
+ },
+ {
+ "name": "display",
+ "inherits": "build-default",
+ "displayName": "display displayName"
+ },
+ {
+ "name": "hidden",
+ "hidden": true
+ }
+ ]
+}
diff --git a/Tests/RunCMake/CMakePresetsBuild/NoConfigurePreset-build-noConfigurePreset-result.txt b/Tests/RunCMake/CMakePresetsBuild/NoConfigurePreset-build-noConfigurePreset-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/NoConfigurePreset-build-noConfigurePreset-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CMakePresetsBuild/NoConfigurePreset-build-noConfigurePreset-stderr.txt b/Tests/RunCMake/CMakePresetsBuild/NoConfigurePreset-build-noConfigurePreset-stderr.txt
new file mode 100644
index 0000000..fcb37bc
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/NoConfigurePreset-build-noConfigurePreset-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error: Could not read presets from [^
+]*/Tests/RunCMake/CMakePresetsBuild/NoConfigurePreset: Invalid preset
diff --git a/Tests/RunCMake/CMakePresetsBuild/NoConfigurePreset.cmake b/Tests/RunCMake/CMakePresetsBuild/NoConfigurePreset.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/NoConfigurePreset.cmake
diff --git a/Tests/RunCMake/CMakePresetsBuild/NoConfigurePreset.json.in b/Tests/RunCMake/CMakePresetsBuild/NoConfigurePreset.json.in
new file mode 100644
index 0000000..81b2cde
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/NoConfigurePreset.json.in
@@ -0,0 +1,15 @@
+{
+ "version": 2,
+ "configurePresets": [
+ {
+ "name": "default",
+ "generator": "@RunCMake_GENERATOR@",
+ "binaryDir": "${sourceDir}/build/${presetName}"
+ }
+ ],
+ "buildPresets": [
+ {
+ "name": "noConfigurePreset"
+ }
+ ]
+}
diff --git a/Tests/RunCMake/CMakePresetsBuild/PresetsUnsupported-build-x-result.txt b/Tests/RunCMake/CMakePresetsBuild/PresetsUnsupported-build-x-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/PresetsUnsupported-build-x-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CMakePresetsBuild/PresetsUnsupported-build-x-stderr.txt b/Tests/RunCMake/CMakePresetsBuild/PresetsUnsupported-build-x-stderr.txt
new file mode 100644
index 0000000..d6ae62d
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/PresetsUnsupported-build-x-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error: Could not read presets from [^
+]*Tests/RunCMake/CMakePresetsBuild/PresetsUnsupported: File version must be 2 or higher for build and test preset support.
diff --git a/Tests/RunCMake/CMakePresetsBuild/PresetsUnsupported.json.in b/Tests/RunCMake/CMakePresetsBuild/PresetsUnsupported.json.in
new file mode 100644
index 0000000..0028239
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/PresetsUnsupported.json.in
@@ -0,0 +1,7 @@
+{
+ "version": 1,
+ "configurePresets": [
+ ],
+ "buildPresets": [
+ ]
+}
diff --git a/Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake
new file mode 100644
index 0000000..9491524
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake
@@ -0,0 +1,67 @@
+include(RunCMake)
+
+# Presets do not support legacy VS generator name architecture suffix.
+if(RunCMake_GENERATOR MATCHES "^(Visual Studio [0-9]+ [0-9]+) ")
+ set(RunCMake_GENERATOR "${CMAKE_MATCH_1}")
+endif()
+
+function(run_cmake_build_presets name CMakePresetsBuild_CONFIGURE_PRESETS CMakePresetsBuild_BUILD_PRESETS)
+ set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/${name}")
+ set(RunCMake_TEST_BINARY_DIR "${RunCMake_TEST_SOURCE_DIR}/build")
+ set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_SOURCE_DIR}")
+
+ set(RunCMake_TEST_NO_CLEAN TRUE)
+
+ file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+ set(CASE_NAME "${name}")
+ set(CASE_SOURCE_DIR "${RunCMake_SOURCE_DIR}")
+ configure_file("${RunCMake_SOURCE_DIR}/CMakeLists.txt.in" "${RunCMake_TEST_SOURCE_DIR}/CMakeLists.txt" @ONLY)
+
+ if(NOT CMakePresetsBuild_FILE)
+ set(CMakePresetsBuild_FILE "${RunCMake_SOURCE_DIR}/${name}.json.in")
+ endif()
+ if(EXISTS "${CMakePresetsBuild_FILE}")
+ configure_file("${CMakePresetsBuild_FILE}" "${RunCMake_TEST_SOURCE_DIR}/CMakePresets.json" @ONLY)
+ endif()
+
+ if(NOT CMakeUserPresets_FILE)
+ set(CMakeUserPresets_FILE "${RunCMake_SOURCE_DIR}/${name}User.json.in")
+ endif()
+ if(EXISTS "${CMakeUserPresets_FILE}")
+ configure_file("${CMakeUserPresets_FILE}" "${RunCMake_TEST_SOURCE_DIR}/CMakeUserPresets.json" @ONLY)
+ endif()
+
+ if (NOT CMakePresetsBuild_BUILD_ONLY)
+ foreach(CONFIGURE_PRESET ${CMakePresetsBuild_CONFIGURE_PRESETS})
+ run_cmake_command("${name}-configure-${CONFIGURE_PRESET}"
+ "${CMAKE_COMMAND}" "--preset" "${CONFIGURE_PRESET}")
+ endforeach()
+ endif()
+
+ foreach(BUILD_PRESET ${CMakePresetsBuild_BUILD_PRESETS})
+ if (EXISTS "${RunCMake_SOURCE_DIR}/${name}-build-${BUILD_PRESET}-check.cmake")
+ set(RunCMake-check-file "${name}-build-${BUILD_PRESET}-check.cmake")
+ else()
+ set(RunCMake-check-file "check.cmake")
+ endif()
+
+ run_cmake_command(${name}-build-${BUILD_PRESET}
+ ${CMAKE_COMMAND} "--build" "--preset" "${BUILD_PRESET}" ${ARGN})
+ endforeach()
+endfunction()
+
+set(CMakePresets_SCHEMA_EXPECTED_RESULT 0)
+
+run_cmake_build_presets(Good "default;other" "build-other;withEnvironment;noEnvironment;macros;vendorObject")
+
+set(CMakePresetsBuild_BUILD_ONLY 1)
+run_cmake_build_presets(ListPresets "x" "x" "--list-presets")
+run_cmake_build_presets(NoConfigurePreset "x" "noConfigurePreset")
+run_cmake_build_presets(Invalid "x" "hidden;vendorMacro;badConfigurePreset")
+
+set(CMakePresets_SCHEMA_EXPECTED_RESULT 1)
+run_cmake_build_presets(PresetsUnsupported "x" "x")
+set(CMakePresets_SCHEMA_EXPECTED_RESULT 0)
+set(CMakePresetsBuild_BUILD_ONLY 0)
diff --git a/Tests/RunCMake/CMakePresetsBuild/TestVariable.cmake b/Tests/RunCMake/CMakePresetsBuild/TestVariable.cmake
new file mode 100644
index 0000000..3113dcc
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/TestVariable.cmake
@@ -0,0 +1,14 @@
+function(test_environment_variable name expected_value)
+ string(REGEX MATCH "${name}=([^\n]*)" REGEX_RESULT "${actual_stdout}")
+ if(NOT REGEX_RESULT)
+ string(APPEND RunCMake_TEST_FAILED "Environment variable '${name}' is not defined.\n")
+ else()
+ set(actual_value "${CMAKE_MATCH_1}")
+ if(NOT "${actual_value}" MATCHES "${expected_value}")
+ string(REPLACE "\n" "\n " _actual "${expected_value}")
+ string(REPLACE "\n" "\n " _expect "${actual_value}")
+ string(APPEND RunCMake_TEST_FAILED "Expected value of environment variable '${name}':\n ${_expect}\nActual value:\n ${_actual}\n")
+ endif()
+ endif()
+ set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
+endfunction()
diff --git a/Tests/RunCMake/CMakePresetsBuild/check.cmake b/Tests/RunCMake/CMakePresetsBuild/check.cmake
new file mode 100644
index 0000000..e79c4f1
--- /dev/null
+++ b/Tests/RunCMake/CMakePresetsBuild/check.cmake
@@ -0,0 +1,3 @@
+set(CMakePresets_VALIDATE_SCRIPT_PATH "${RunCMake_SOURCE_DIR}/../CMakePresets/validate_schema.py")
+include("${RunCMake_SOURCE_DIR}/../CMakePresets/validate_schema.cmake")
+include("${RunCMake_SOURCE_DIR}/../CMakePresets/check.cmake")