summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/RunCMake/CMakePresets/RunCMakeTest.cmake')
-rw-r--r--Tests/RunCMake/CMakePresets/RunCMakeTest.cmake40
1 files changed, 35 insertions, 5 deletions
diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
index 18ea093..dddf05f 100644
--- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
@@ -7,6 +7,24 @@ if(RunCMake_GENERATOR MATCHES "^(Visual Studio [0-9]+ [0-9]+) ")
set(RunCMake_GENERATOR "${CMAKE_MATCH_1}")
endif()
+set(RunCMake-check-file check.cmake)
+
+function(validate_schema file expected_result)
+ execute_process(
+ COMMAND "${PYTHON_EXECUTABLE}" "${RunCMake_SOURCE_DIR}/validate_schema.py" "${file}"
+ RESULT_VARIABLE _result
+ OUTPUT_VARIABLE _output
+ ERROR_VARIABLE _error
+ )
+ if(NOT _result STREQUAL expected_result)
+ string(REPLACE "\n" "\n" _output_p "${_output}")
+ string(REPLACE "\n" "\n" _error_p "${_error}")
+ string(APPEND RunCMake_TEST_FAILED "Expected result of validating ${file}: ${expected_result}\nActual result: ${_result}\nOutput:\n${_output_p}\nError:\n${_error_p}")
+ endif()
+
+ set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
+endfunction()
+
function(run_cmake_presets name)
set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/${name}")
set(_source_arg "${RunCMake_TEST_SOURCE_DIR}")
@@ -57,6 +75,7 @@ function(run_cmake_presets name)
endfunction()
# Test CMakePresets.json errors
+set(CMakePresets_SCHEMA_EXPECTED_RESULT 1)
run_cmake_presets(NoCMakePresets)
run_cmake_presets(JSONParseError)
run_cmake_presets(InvalidRoot)
@@ -65,15 +84,21 @@ run_cmake_presets(InvalidVersion)
run_cmake_presets(LowVersion)
run_cmake_presets(HighVersion)
run_cmake_presets(InvalidVendor)
+set(CMakePresets_SCHEMA_EXPECTED_RESULT 0)
run_cmake_presets(NoPresets)
+set(CMakePresets_SCHEMA_EXPECTED_RESULT 1)
run_cmake_presets(InvalidPresets)
run_cmake_presets(PresetNotObject)
run_cmake_presets(NoPresetName)
run_cmake_presets(InvalidPresetName)
run_cmake_presets(EmptyPresetName)
+set(CMakePresets_SCHEMA_EXPECTED_RESULT 0)
run_cmake_presets(NoPresetGenerator)
+set(CMakePresets_SCHEMA_EXPECTED_RESULT 1)
run_cmake_presets(InvalidPresetGenerator)
+set(CMakePresets_SCHEMA_EXPECTED_RESULT 0)
run_cmake_presets(NoPresetBinaryDir)
+set(CMakePresets_SCHEMA_EXPECTED_RESULT 1)
run_cmake_presets(InvalidPresetBinaryDir)
run_cmake_presets(InvalidVariables)
run_cmake_presets(VariableNotObject)
@@ -83,6 +108,7 @@ run_cmake_presets(ExtraRootField)
run_cmake_presets(ExtraPresetField)
run_cmake_presets(ExtraVariableField)
run_cmake_presets(InvalidPresetVendor)
+set(CMakePresets_SCHEMA_EXPECTED_RESULT 0)
run_cmake_presets(DuplicatePresets)
run_cmake_presets(CyclicInheritance0)
run_cmake_presets(CyclicInheritance1)
@@ -90,13 +116,22 @@ run_cmake_presets(CyclicInheritance2)
run_cmake_presets(InvalidInheritance)
run_cmake_presets(ErrorNoWarningDev)
run_cmake_presets(ErrorNoWarningDeprecated)
+set(CMakePresets_SCHEMA_EXPECTED_RESULT 1)
run_cmake_presets(InvalidCMakeGeneratorConfig)
run_cmake_presets(UnknownCMakeGeneratorConfig)
run_cmake_presets(EmptyCacheKey)
run_cmake_presets(EmptyEnvKey)
+set(CMakePresets_SCHEMA_EXPECTED_RESULT 0)
+run_cmake_presets(UnclosedMacro)
+run_cmake_presets(NoSuchMacro)
+run_cmake_presets(EnvCycle)
+run_cmake_presets(EmptyEnv)
+run_cmake_presets(EmptyPenv)
+set(CMakePresets_SCHEMA_EXPECTED_RESULT 1)
# Test cmakeMinimumRequired field
run_cmake_presets(MinimumRequiredInvalid)
+set(CMakePresets_SCHEMA_EXPECTED_RESULT 0)
run_cmake_presets(MinimumRequiredEmpty)
run_cmake_presets(MinimumRequiredMajor)
run_cmake_presets(MinimumRequiredMinor)
@@ -142,13 +177,8 @@ run_cmake_presets(GoodInheritanceMultiSecond)
run_cmake_presets(GoodInheritanceMacro)
# Test bad preset arguments
-run_cmake_presets(UnclosedMacro)
-run_cmake_presets(NoSuchMacro)
run_cmake_presets(VendorMacro)
run_cmake_presets(InvalidGenerator)
-run_cmake_presets(EnvCycle)
-run_cmake_presets(EmptyEnv)
-run_cmake_presets(EmptyPenv)
# Test Visual Studio-specific stuff
if(RunCMake_GENERATOR MATCHES "^Visual Studio ")