Skip to content

Commit

Permalink
test: add test for execute process assertion functions
Browse files Browse the repository at this point in the history
  • Loading branch information
threeal committed May 17, 2024
1 parent b93bd1a commit d8bca24
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ add_cmake_test(
"Assert unequal strings"
"Mock message"
"Assert messages"
"Assert successful process execution"
"Assert failed process execution"
)
18 changes: 18 additions & 0 deletions test/cmake/AssertionTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,22 @@ function("Assert messages")
assert_message(FATAL_ERROR "expected error message '' to be equal to 'some other error message'")
endfunction()

function("Assert successful process execution")
assert_execute_process("${CMAKE_COMMAND}" -E true)

mock_message()
assert_not_execute_process("${CMAKE_COMMAND}" -E true)
end_mock_message()
assert_message(FATAL_ERROR "expected command '${CMAKE_COMMAND} -E true' to fail (exit code: 0)")
endfunction()

function("Assert failed process execution")
mock_message()
assert_execute_process("${CMAKE_COMMAND}" -E false)
end_mock_message()
assert_message(FATAL_ERROR "expected command '${CMAKE_COMMAND} -E false' not to fail (exit code: 1)")

assert_not_execute_process("${CMAKE_COMMAND}" -E false)
endfunction()

cmake_language(CALL "${TEST_COMMAND}")

0 comments on commit d8bca24

Please sign in to comment.