Skip to content

Commit

Permalink
feat: add mock_message function
Browse files Browse the repository at this point in the history
  • Loading branch information
threeal committed May 3, 2024
1 parent 92f3bf7 commit 9c0e411
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cmake/Assertion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,21 @@ function(assert_false CONDITION)
message(FATAL_ERROR "expected the condition to be false")
endif()
endfunction()

# Mocks the 'message' function.
#
# This function mocks the 'message' function by modifying its behavior to store
# the message into a list variable instead of printing it to the log.
function(mock_message)
function(message MODE MESSAGE)
list(APPEND ${MODE}_MESSAGES "${MESSAGE}")
set(${MODE}_MESSAGES "${${MODE}_MESSAGES}" PARENT_SCOPE)
if("${MODE}" STREQUAL FATAL_ERROR)
return()
endif()
endfunction()

# Prevents the function from being mocked twice.
function(mock_message)
endfunction()
endfunction()

0 comments on commit 9c0e411

Please sign in to comment.