Tests/CXXModules: fix error detection propagation

This commit is contained in:
Ben Boeckel
2023-09-25 11:04:42 -04:00
parent 7a4c02cb38
commit 1c9f83c8ec
4 changed files with 15 additions and 2 deletions

View File

@@ -32,3 +32,5 @@ else ()
file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoBMIInstall-private.json" expect_contents)
check_json("${actual_contents}" "${expect_contents}")
endif ()
string(REPLACE ";" "\n " RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}")

View File

@@ -32,3 +32,5 @@ else ()
file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoExport-private.json" expect_contents)
check_json("${actual_contents}" "${expect_contents}")
endif ()
string(REPLACE ";" "\n " RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}")

View File

@@ -32,3 +32,5 @@ else ()
file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoFileSet-private.json" expect_contents)
check_json("${actual_contents}" "${expect_contents}")
endif ()
string(REPLACE ";" "\n " RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}")

View File

@@ -22,6 +22,7 @@ function (check_json_value path actual_type expect_type actual_value expect_valu
if (NOT actual_type STREQUAL expect_type)
list(APPEND RunCMake_TEST_FAILED
"Type mismatch at ${path}: ${actual_type} vs. ${expect_type}")
set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
return ()
endif ()
@@ -53,6 +54,8 @@ function (check_json_value path actual_type expect_type actual_value expect_valu
elseif (actual_type STREQUAL OBJECT)
check_json_object("${path}" "${actual_value}" "${expect_value}")
endif ()
set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
endfunction ()
# Check that two arrays are the same.
@@ -82,6 +85,8 @@ function (check_json_array path actual expect)
string(JSON expect_value GET "${expect}" "${idx}")
check_json_value("${new_path}" "${actual_type}" "${expect_type}" "${actual_value}" "${expect_value}")
endforeach ()
set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
endfunction ()
# Check that two inner objects are the same.
@@ -148,13 +153,15 @@ function (check_json_object path actual expect)
string(JSON expect_value GET "${expect}" "${key}")
check_json_value("${new_path}" "${actual_type}" "${expect_type}" "${actual_value}" "${expect_value}")
endforeach ()
set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
endfunction ()
# Check that two JSON objects are the same.
function (check_json actual expect)
check_json_object("" "${actual}" "${expect}")
set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
endfunction ()
string(REPLACE ";" "; " RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}")
cmake_policy(POP)