diff options
Diffstat (limited to 'Tests/RunCMake/CMakePresetsTest')
41 files changed, 482 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakePresetsTest/CMakeLists.txt.in b/Tests/RunCMake/CMakePresetsTest/CMakeLists.txt.in new file mode 100644 index 0000000..129184a --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/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/CMakePresetsTest/Good-indexFile.txt b/Tests/RunCMake/CMakePresetsTest/Good-indexFile.txt new file mode 100644 index 0000000..4ac2314 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/Good-indexFile.txt @@ -0,0 +1 @@ +2,,2 diff --git a/Tests/RunCMake/CMakePresetsTest/Good-test-config-debug-stdout.txt b/Tests/RunCMake/CMakePresetsTest/Good-test-config-debug-stdout.txt new file mode 100644 index 0000000..c281c81 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/Good-test-config-debug-stdout.txt @@ -0,0 +1,5 @@ +Test project [^ +]*/Tests/RunCMake/CMakePresetsTest/Good/build/default + Start 6: debug-only +.* +100% tests passed, 0 tests failed out of 1 diff --git a/Tests/RunCMake/CMakePresetsTest/Good-test-config-release-stdout.txt b/Tests/RunCMake/CMakePresetsTest/Good-test-config-release-stdout.txt new file mode 100644 index 0000000..66bfd22 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/Good-test-config-release-stdout.txt @@ -0,0 +1,5 @@ +Test project [^ +]*/Tests/RunCMake/CMakePresetsTest/Good/build/default + Start 6: release-only +.* +100% tests passed, 0 tests failed out of 1 diff --git a/Tests/RunCMake/CMakePresetsTest/Good-test-exclude-stdout.txt b/Tests/RunCMake/CMakePresetsTest/Good-test-exclude-stdout.txt new file mode 100644 index 0000000..5e990de --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/Good-test-exclude-stdout.txt @@ -0,0 +1,7 @@ +Test project [^ +]*/Tests/RunCMake/CMakePresetsTest/Good/build/default + Start 3: testc +.* + Start 4: testd +.* +100% tests passed, 0 tests failed out of 2 diff --git a/Tests/RunCMake/CMakePresetsTest/Good-test-index-stdout.txt b/Tests/RunCMake/CMakePresetsTest/Good-test-index-stdout.txt new file mode 100644 index 0000000..2df6fcb --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/Good-test-index-stdout.txt @@ -0,0 +1,7 @@ +Test project [^ +]*/Tests/RunCMake/CMakePresetsTest/Good/build/default + Start 1: testa +.* + Start 3: testc +.* +100% tests passed, 0 tests failed out of 2 diff --git a/Tests/RunCMake/CMakePresetsTest/Good-test-indexFile-stdout.txt b/Tests/RunCMake/CMakePresetsTest/Good-test-indexFile-stdout.txt new file mode 100644 index 0000000..1366876 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/Good-test-indexFile-stdout.txt @@ -0,0 +1,7 @@ +Test project [^ +]*/Tests/RunCMake/CMakePresetsTest/Good/build/default + Start 2: testb +.* + Start 4: testd +.* +100% tests passed, 0 tests failed out of 2 diff --git a/Tests/RunCMake/CMakePresetsTest/Good-test-noEnvironment-stdout.txt b/Tests/RunCMake/CMakePresetsTest/Good-test-noEnvironment-stdout.txt new file mode 100644 index 0000000..8b4845e --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/Good-test-noEnvironment-stdout.txt @@ -0,0 +1,8 @@ +Test project [^ +]*/Tests/RunCMake/CMakePresetsTest/Good/build/default +.* + Start 5: test-env +.* +5: TEST_ENV_REF=xx +.* +100% tests passed, 0 tests failed out of 1 diff --git a/Tests/RunCMake/CMakePresetsTest/Good-test-showOnly-stdout.txt b/Tests/RunCMake/CMakePresetsTest/Good-test-showOnly-stdout.txt new file mode 100644 index 0000000..67ddd4f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/Good-test-showOnly-stdout.txt @@ -0,0 +1,8 @@ +Test project [^ +]*/Tests/RunCMake/CMakePresetsTest/Good/build/default + Test #1: testa + Test #2: testb + Test #3: testc + Test #4: testd + +Total Tests: 4 diff --git a/Tests/RunCMake/CMakePresetsTest/Good-withEnvironment-check.cmake b/Tests/RunCMake/CMakePresetsTest/Good-withEnvironment-check.cmake new file mode 100644 index 0000000..0c19556 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/Good-withEnvironment-check.cmake @@ -0,0 +1,8 @@ +include("${RunCMake_SOURCE_DIR}/../CMakePresetsBuild/TestVariable.cmake") + +test_environment_variable("TEST_ENV" "Environment variable") +test_environment_variable("TEST_ENV_OVERRIDE" "Override") +test_environment_variable("TEST_ENV_OVERRIDE_REF" "xOverridex") +test_environment_variable("TEST_ENV_REF" "xEnvironment variablex") + +include("${RunCMake_SOURCE_DIR}/check.cmake") diff --git a/Tests/RunCMake/CMakePresetsTest/Good.cmake b/Tests/RunCMake/CMakePresetsTest/Good.cmake new file mode 100644 index 0000000..0a6cf57 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/Good.cmake @@ -0,0 +1,27 @@ +enable_testing() +add_test(testa ${CMAKE_COMMAND} -E echo testa) +add_test(testb ${CMAKE_COMMAND} -E echo testb) +add_test(testc ${CMAKE_COMMAND} -E echo testc) +add_test(testd ${CMAKE_COMMAND} -E echo testd) + +set_tests_properties(testa testb testc testd + PROPERTIES LABELS "echo") +set_property(TEST testa testb + APPEND PROPERTY LABELS ab) +set_property(TEST testb testc + APPEND PROPERTY LABELS bc) +set_property(TEST testc testd + APPEND PROPERTY LABELS cd) + +add_test(test-env ${CMAKE_COMMAND} -E environment | sort) +set_tests_properties(test-env PROPERTIES LABELS "env") + +add_test(NAME debug-only + COMMAND ${CMAKE_COMMAND} -E echo debug-only + CONFIGURATIONS Debug) +add_test(NAME release-only + COMMAND ${CMAKE_COMMAND} -E echo release-only + CONFIGURATIONS Release) + +set_tests_properties(debug-only release-only + PROPERTIES LABELS "config") diff --git a/Tests/RunCMake/CMakePresetsTest/Good.json.in b/Tests/RunCMake/CMakePresetsTest/Good.json.in new file mode 100644 index 0000000..57be5a5 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/Good.json.in @@ -0,0 +1,175 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "default", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build/${presetName}", + "environment": { + "TEST_ENV": "Environment variable", + "TEST_ENV_OVERRIDE": "Overridden environment variable" + } + } + ], + "buildPresets": [ + { + "name": "build-default-debug", + "configurePreset": "default", + "configuration": "Debug" + }, + { + "name": "build-default-release", + "inherits": "build-default-debug", + "configuration": "Release" + } + ], + "testPresets": [ + { + "name": "minimal", + "configurePreset": "default" + }, + { + "name": "defaults", + "hidden": false, + "inherits": [], + "vendor": {}, + "displayName": "", + "description": "", + "environment": {}, + "configurePreset": "default", + "inheritConfigureEnvironment": true, + "configuration": "", + "overwriteConfigurationFile": [], + "output": { + "shortProgress": false, + "verbosity": "default", + "debug": false, + "outputOnFailure": false, + "quiet": false, + "outputLogFile": "", + "labelSummary": true, + "subprojectSummary": true + }, + "filter": { + "include": { + "name": "", + "label": "", + "useUnion": false, + "index": "" + }, + "exclude": { + "name": "", + "label": "", + "fixtures": { + "any": "", + "setup": "", + "cleanup": "" + } + } + }, + "execution": { + "stopOnFailure": false, + "enableFailover": false, + "jobs": 0, + "resourceSpecFile": "", + "showOnly": "human", + "repeat": { + "mode": "until-pass", + "count": 1 + }, + "interactiveDebugging": false, + "scheduleRandom": false, + "noTestsAction": "default" + } + }, + { + "name": "noEnvironment", + "configurePreset": "default", + "inheritConfigureEnvironment": false, + "environment": { + "TEST_ENV_REF": "x$env{TEST_ENV}x" + }, + "filter": { + "include": { + "name": "test-env" + } + }, + "output": { + "verbosity": "verbose" + } + }, + { + "name": "withEnvironment", + "inherits": "noEnvironment", + "inheritConfigureEnvironment": true, + "environment": { + "TEST_ENV_OVERRIDE": "Override", + "TEST_ENV_OVERRIDE_REF": "x$env{TEST_ENV_OVERRIDE}x", + "TEST_ENV_REF": "x$env{TEST_ENV}x" + } + }, + { + "name": "config-debug", + "inherits": "minimal", + "configuration": "Debug", + "filter": { + "include": { + "label": "config" + } + } + }, + { + "name": "config-release", + "inherits": "minimal", + "configuration": "Release", + "filter": { + "include": { + "label": "config" + } + } + }, + { + "name": "exclude", + "inherits": "minimal", + "filter": { + "exclude": { + "name": "test-env", + "label": "(ab|config)" + } + } + }, + { + "name": "index", + "inherits": "minimal", + "filter": { + "include": { + "index": { + "end": 4, + "stride": 2 + } + } + } + }, + { + "name": "indexFile", + "inherits": "minimal", + "filter": { + "include": { + "index": "${sourceDir}/Good-indexFile.txt" + } + } + }, + { + "name": "showOnly", + "inherits": "minimal", + "filter": { + "include": { + "label": "echo" + } + }, + "execution": { + "showOnly": "human" + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsTest/Invalid-test-badConfigurePreset-result.txt b/Tests/RunCMake/CMakePresetsTest/Invalid-test-badConfigurePreset-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/Invalid-test-badConfigurePreset-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresetsTest/Invalid-test-badConfigurePreset-stderr.txt b/Tests/RunCMake/CMakePresetsTest/Invalid-test-badConfigurePreset-stderr.txt new file mode 100644 index 0000000..9cf9987 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/Invalid-test-badConfigurePreset-stderr.txt @@ -0,0 +1,2 @@ +CMake Error: No such configure preset in [^ +]*/Tests/RunCMake/CMakePresetsTest/Invalid: "dne" diff --git a/Tests/RunCMake/CMakePresetsTest/Invalid-test-hidden-result.txt b/Tests/RunCMake/CMakePresetsTest/Invalid-test-hidden-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/Invalid-test-hidden-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresetsTest/Invalid-test-hidden-stderr.txt b/Tests/RunCMake/CMakePresetsTest/Invalid-test-hidden-stderr.txt new file mode 100644 index 0000000..41b1b4e --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/Invalid-test-hidden-stderr.txt @@ -0,0 +1,2 @@ +CMake Error: Cannot use hidden test preset in [^ +]*/Tests/RunCMake/CMakePresetsTest/Invalid: "hidden" diff --git a/Tests/RunCMake/CMakePresetsTest/Invalid-test-vendorMacro-result.txt b/Tests/RunCMake/CMakePresetsTest/Invalid-test-vendorMacro-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/Invalid-test-vendorMacro-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresetsTest/Invalid-test-vendorMacro-stderr.txt b/Tests/RunCMake/CMakePresetsTest/Invalid-test-vendorMacro-stderr.txt new file mode 100644 index 0000000..ed5bb98 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/Invalid-test-vendorMacro-stderr.txt @@ -0,0 +1 @@ +CMake Error: Could not evaluate test preset "vendorMacro": Invalid macro expansion diff --git a/Tests/RunCMake/CMakePresetsTest/Invalid.cmake b/Tests/RunCMake/CMakePresetsTest/Invalid.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/Invalid.cmake diff --git a/Tests/RunCMake/CMakePresetsTest/Invalid.json.in b/Tests/RunCMake/CMakePresetsTest/Invalid.json.in new file mode 100644 index 0000000..cfcf4b7 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/Invalid.json.in @@ -0,0 +1,23 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "default", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build/${presetName}" + } + ], + "testPresets": [ + { + "name": "hidden", + "hidden": true + }, + { + "name": "vendorMacro", + "configurePreset": "default", + "environment": { + "TEST": "$vendor{bad.TEST}" + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsTest/InvalidConfigurePreset-configure-default-result.txt b/Tests/RunCMake/CMakePresetsTest/InvalidConfigurePreset-configure-default-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/InvalidConfigurePreset-configure-default-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresetsTest/InvalidConfigurePreset-configure-default-stderr.txt b/Tests/RunCMake/CMakePresetsTest/InvalidConfigurePreset-configure-default-stderr.txt new file mode 100644 index 0000000..3d7cdd0 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/InvalidConfigurePreset-configure-default-stderr.txt @@ -0,0 +1,2 @@ +CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresetsTest/InvalidConfigurePreset: Invalid "configurePreset" field diff --git a/Tests/RunCMake/CMakePresetsTest/InvalidConfigurePreset-test-badConfigurePreset-result.txt b/Tests/RunCMake/CMakePresetsTest/InvalidConfigurePreset-test-badConfigurePreset-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/InvalidConfigurePreset-test-badConfigurePreset-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresetsTest/InvalidConfigurePreset-test-badConfigurePreset-stderr.txt b/Tests/RunCMake/CMakePresetsTest/InvalidConfigurePreset-test-badConfigurePreset-stderr.txt new file mode 100644 index 0000000..3d7cdd0 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/InvalidConfigurePreset-test-badConfigurePreset-stderr.txt @@ -0,0 +1,2 @@ +CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresetsTest/InvalidConfigurePreset: Invalid "configurePreset" field diff --git a/Tests/RunCMake/CMakePresetsTest/InvalidConfigurePreset.cmake b/Tests/RunCMake/CMakePresetsTest/InvalidConfigurePreset.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/InvalidConfigurePreset.cmake diff --git a/Tests/RunCMake/CMakePresetsTest/InvalidConfigurePreset.json.in b/Tests/RunCMake/CMakePresetsTest/InvalidConfigurePreset.json.in new file mode 100644 index 0000000..e305c42 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/InvalidConfigurePreset.json.in @@ -0,0 +1,16 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "default", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build/${presetName}" + } + ], + "testPresets": [ + { + "name": "badConfigurePreset", + "configurePreset": "dne" + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsTest/ListPresets-test-x-stdout.txt b/Tests/RunCMake/CMakePresetsTest/ListPresets-test-x-stdout.txt new file mode 100644 index 0000000..46ffbcf --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/ListPresets-test-x-stdout.txt @@ -0,0 +1,12 @@ +Available test presets: + + "minimal" + "defaults" + "noEnvironment" + "withEnvironment" + "config-debug" + "config-release" + "exclude" + "index" + "indexFile" + "showOnly" diff --git a/Tests/RunCMake/CMakePresetsTest/ListPresets.cmake b/Tests/RunCMake/CMakePresetsTest/ListPresets.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/ListPresets.cmake diff --git a/Tests/RunCMake/CMakePresetsTest/NoConfigurePreset-test-noConfigurePreset-result.txt b/Tests/RunCMake/CMakePresetsTest/NoConfigurePreset-test-noConfigurePreset-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/NoConfigurePreset-test-noConfigurePreset-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresetsTest/NoConfigurePreset-test-noConfigurePreset-stderr.txt b/Tests/RunCMake/CMakePresetsTest/NoConfigurePreset-test-noConfigurePreset-stderr.txt new file mode 100644 index 0000000..b167f68 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/NoConfigurePreset-test-noConfigurePreset-stderr.txt @@ -0,0 +1,2 @@ +CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresetsTest/NoConfigurePreset: Invalid preset diff --git a/Tests/RunCMake/CMakePresetsTest/NoConfigurePreset.cmake b/Tests/RunCMake/CMakePresetsTest/NoConfigurePreset.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/NoConfigurePreset.cmake diff --git a/Tests/RunCMake/CMakePresetsTest/NoConfigurePreset.json.in b/Tests/RunCMake/CMakePresetsTest/NoConfigurePreset.json.in new file mode 100644 index 0000000..4591cc8 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/NoConfigurePreset.json.in @@ -0,0 +1,15 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "default", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build/${presetName}" + } + ], + "testPresets": [ + { + "name": "noConfigurePreset" + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsTest/NoTestsAction-test-noTestsAction-result.txt b/Tests/RunCMake/CMakePresetsTest/NoTestsAction-test-noTestsAction-result.txt new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/NoTestsAction-test-noTestsAction-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/CMakePresetsTest/NoTestsAction-test-noTestsAction-stderr.txt b/Tests/RunCMake/CMakePresetsTest/NoTestsAction-test-noTestsAction-stderr.txt new file mode 100644 index 0000000..eafba1c --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/NoTestsAction-test-noTestsAction-stderr.txt @@ -0,0 +1 @@ +No tests were found!!! diff --git a/Tests/RunCMake/CMakePresetsTest/NoTestsAction.cmake b/Tests/RunCMake/CMakePresetsTest/NoTestsAction.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/NoTestsAction.cmake diff --git a/Tests/RunCMake/CMakePresetsTest/NoTestsAction.json.in b/Tests/RunCMake/CMakePresetsTest/NoTestsAction.json.in new file mode 100644 index 0000000..20a50d6 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/NoTestsAction.json.in @@ -0,0 +1,19 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "default", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build/${presetName}" + } + ], + "testPresets": [ + { + "name": "noTestsAction", + "configurePreset": "default", + "execution": { + "noTestsAction": "error" + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsTest/PresetsUnsupported-test-x-result.txt b/Tests/RunCMake/CMakePresetsTest/PresetsUnsupported-test-x-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/PresetsUnsupported-test-x-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresetsTest/PresetsUnsupported-test-x-stderr.txt b/Tests/RunCMake/CMakePresetsTest/PresetsUnsupported-test-x-stderr.txt new file mode 100644 index 0000000..eb0ec1a --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/PresetsUnsupported-test-x-stderr.txt @@ -0,0 +1,2 @@ +CMake Error: Could not read presets from [^ +]*Tests/RunCMake/CMakePresetsTest/PresetsUnsupported: File version must be 2 or higher for build and test preset support. diff --git a/Tests/RunCMake/CMakePresetsTest/PresetsUnsupported.json.in b/Tests/RunCMake/CMakePresetsTest/PresetsUnsupported.json.in new file mode 100644 index 0000000..ff1b000 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/PresetsUnsupported.json.in @@ -0,0 +1,7 @@ +{ + "version": 1, + "configurePresets": [ + ], + "testPresets": [ + ] +} diff --git a/Tests/RunCMake/CMakePresetsTest/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresetsTest/RunCMakeTest.cmake new file mode 100644 index 0000000..c93dff3 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/RunCMakeTest.cmake @@ -0,0 +1,104 @@ +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_test_presets name CMakePresetsTest_CONFIGURE_PRESETS CMakePresetsTest_BUILD_PRESETS CMakePresetsTest_TEST_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 CMakePresetsTest_FILE) + set(CMakePresetsTest_FILE "${RunCMake_SOURCE_DIR}/${name}.json.in") + endif() + if(EXISTS "${CMakePresetsTest_FILE}") + configure_file("${CMakePresetsTest_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() + + foreach(ASSET ${CMakePresetsTest_ASSETS}) + configure_file("${RunCMake_SOURCE_DIR}/${ASSET}" "${RunCMake_TEST_SOURCE_DIR}" COPYONLY) + endforeach() + + if (NOT CMakePresetsTest_NO_CONFIGURE) + foreach(CONFIGURE_PRESET ${CMakePresetsTest_CONFIGURE_PRESETS}) + run_cmake_command("${name}-configure-${CONFIGURE_PRESET}" + "${CMAKE_COMMAND}" "--preset" "${CONFIGURE_PRESET}") + endforeach() + endif() + + if (NOT CMakePresetsTest_NO_BUILD) + foreach(BUILD_PRESET ${CMakePresetsTest_BUILD_PRESETS}) + run_cmake_command("${name}-build-${BUILD_PRESET}" + "${CMAKE_COMMAND}" "--build" "--preset" "${BUILD_PRESET}") + endforeach() + endif() + + set(eq 0) + foreach(TEST_PRESET ${CMakePresetsTest_TEST_PRESETS}) + if (EXISTS "${RunCMake_SOURCE_DIR}/${name}-test-${TEST_PRESET}-check.cmake") + set(RunCMake-check-file "${name}-test-${TEST_PRESET}-check.cmake") + else() + set(RunCMake-check-file "check.cmake") + endif() + + if(eq) + run_cmake_command(${name}-test-${TEST_PRESET} + ${CMAKE_CTEST_COMMAND} "--preset=${TEST_PRESET}" ${ARGN}) + set(eq 0) + else() + run_cmake_command(${name}-test-${TEST_PRESET} + ${CMAKE_CTEST_COMMAND} "--preset" "${TEST_PRESET}" ${ARGN}) + set(eq 1) + endif() + endforeach() +endfunction() + +set(CMakePresets_SCHEMA_EXPECTED_RESULT 0) +set(CMakePresetsTest_NO_BUILD 1) + +set(CMakePresetsTest_ASSETS "Good-indexFile.txt") +set(GoodTestPresets + "minimal;defaults;noEnvironment;withEnvironment" + "config-debug;config-release" + "exclude;index;indexFile;showOnly") +run_cmake_test_presets(Good + "default" + "" + "${GoodTestPresets}") +unset(CMakePresetsTest_ASSETS) + +run_cmake_test_presets(InvalidConfigurePreset "default" "" "badConfigurePreset") + +set(CMakePresetsTest_NO_CONFIGURE 1) +set(CMakePresetsTest_FILE "${RunCMake_SOURCE_DIR}/Good.json.in") +run_cmake_test_presets(ListPresets "" "" "x" "--list-presets") +unset(CMakePresetsTest_FILE) + +run_cmake_test_presets(NoConfigurePreset "" "" "noConfigurePreset") +run_cmake_test_presets(NoTestsAction "default" "" "noTestsAction") +run_cmake_test_presets(Invalid "" "" "hidden;vendorMacro") + +set(CMakePresets_SCHEMA_EXPECTED_RESULT 1) +run_cmake_test_presets(PresetsUnsupported "" "" "x") +set(CMakePresets_SCHEMA_EXPECTED_RESULT 0) +set(CMakePresetsTest_NO_CONFIGURE 0) + +set(CMakePresetsTest_NO_BUILD 0) diff --git a/Tests/RunCMake/CMakePresetsTest/check.cmake b/Tests/RunCMake/CMakePresetsTest/check.cmake new file mode 100644 index 0000000..e79c4f1 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/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") |