summaryrefslogtreecommitdiffstats
path: root/Tests
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:00:42 (GMT)
commit56751c83aa1b9de7f3c785b17922eb9af6bc9e4a (patch)
tree3a496f6f7a898ac0816863846b0704e8f6f3acce /Tests
parent676ecf0d37cf5cfda390f52ce60babcb5da78108 (diff)
downloadCMake-56751c83aa1b9de7f3c785b17922eb9af6bc9e4a.zip
CMake-56751c83aa1b9de7f3c785b17922eb9af6bc9e4a.tar.gz
CMake-56751c83aa1b9de7f3c785b17922eb9af6bc9e4a.tar.bz2
Tests: Factor out RunCMake.CMakePresets schema validation
Make it available to similar tests. Also fix whitespace in generated error message.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CMakePresets/RunCMakeTest.cmake16
-rw-r--r--Tests/RunCMake/CMakePresets/validate_schema.cmake19
2 files changed, 20 insertions, 15 deletions
diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
index 1ffda3d..25a7f2f 100644
--- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
@@ -9,21 +9,7 @@ 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()
+include("${RunCMake_SOURCE_DIR}/validate_schema.cmake")
function(run_cmake_presets name)
set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/${name}")
diff --git a/Tests/RunCMake/CMakePresets/validate_schema.cmake b/Tests/RunCMake/CMakePresets/validate_schema.cmake
new file mode 100644
index 0000000..68b638f
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/validate_schema.cmake
@@ -0,0 +1,19 @@
+function(validate_schema file expected_result)
+ if (NOT CMakePresets_VALIDATE_SCRIPT_PATH)
+ set(CMakePresets_VALIDATE_SCRIPT_PATH "${RunCMake_SOURCE_DIR}/validate_schema.py")
+ endif()
+
+ execute_process(
+ COMMAND "${PYTHON_EXECUTABLE}" "${CMakePresets_VALIDATE_SCRIPT_PATH}" "${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}\n")
+ endif()
+
+ set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
+endfunction()