Skip to content

Commit

Permalink
feat: make CALL option in assert_call function to be optional (#278)
Browse files Browse the repository at this point in the history
Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>
  • Loading branch information
threeal authored Oct 18, 2024
1 parent cc3970d commit 6742c78
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 232 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ assert(IS_DIRECTORY "${CMAKE_STARTER_DIR}")
assert_execute_process(
git -C "${CMAKE_STARTER_DIR}" rev-parse --is-inside-work-tree)
assert_call(
CALL git_clone https://github.com GITHUB_DIR
assert_call(git_clone https://github.com GITHUB_DIR
EXPECT_FATAL_ERROR "failed to clone 'https://github.com'")
```

Expand Down Expand Up @@ -175,7 +174,7 @@ Performs an assertion on the given command call.

```cmake
assert_call(
CALL <command> [<arguments>...]
[CALL] <command> [<arguments>...]
EXPECT_FATAL_ERROR [MATCHES|STREQUAL] <message>...)
```

Expand Down
6 changes: 5 additions & 1 deletion cmake/Assertion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ endfunction()
# Performs an assertion on the given command call.
#
# assert_call(
# CALL <command> [<arguments>...]
# [CALL] <command> [<arguments>...]
# EXPECT_FATAL_ERROR [MATCHES|STREQUAL] <message>...)
#
# This function performs an assertion on the function or macro named
Expand All @@ -375,6 +375,10 @@ endfunction()
function(assert_call)
cmake_parse_arguments(PARSE_ARGV 0 ARG "" "" "CALL;EXPECT_FATAL_ERROR")

if(NOT DEFINED ARG_CALL)
set(ARG_CALL ${ARG_UNPARSED_ARGUMENTS})
endif()

list(GET ARG_EXPECT_FATAL_ERROR 0 OPERATOR)
if(OPERATOR MATCHES ^MATCHES|STREQUAL$)
list(REMOVE_AT ARG_EXPECT_FATAL_ERROR 0)
Expand Down
Loading

0 comments on commit 6742c78

Please sign in to comment.