Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Assertion.cmake to Version 2.0.0 #132

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ include(cmake/MyProject.cmake)
if(MY_PROJECT_ENABLE_TESTS)
enable_testing()

find_package(Assertion 1.0.0 REQUIRED)
assertion_add_test(test/test_git_clone.cmake)
find_package(Assertion 2.0.0 REQUIRED)
list(APPEND CMAKE_SCRIPT_TEST_DEFINITIONS CMAKE_MODULE_PATH)

add_cmake_script_test(test/test_git_clone.cmake)
endif()

# TODO: Replace `MY_PROJECT_ENABLE_INSTALL` with the correct option.
Expand Down
9 changes: 6 additions & 3 deletions cmake/FindAssertion.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
file(
DOWNLOAD https://github.com/threeal/assertion-cmake/releases/download/v1.0.0/Assertion.cmake
DOWNLOAD https://github.com/threeal/assertion-cmake/releases/download/v2.0.0/Assertion.cmake
${CMAKE_BINARY_DIR}/cmake/Assertion.cmake
EXPECTED_MD5 1d8ec589d6cc15772581bf77eb3873ff)
EXPECTED_MD5 5ebe475aee6fc5660633152f815ce9f6)
include(${CMAKE_BINARY_DIR}/cmake/Assertion.cmake)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Assertion REQUIRED_VARS ASSERTION_LIST_FILE)
find_package_handle_standard_args(
Assertion REQUIRED_VARS ASSERTION_VERSION VERSION_VAR ASSERTION_VERSION)

list(PREPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}/cmake)
9 changes: 6 additions & 3 deletions test/test_git_clone.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
cmake_minimum_required(VERSION 3.21)

include(Assertion)

# TODO: Replace `MyProject.cmake` with the correct main module file.
include(${CMAKE_CURRENT_LIST_DIR}/../cmake/MyProject.cmake)

Expand All @@ -13,9 +17,8 @@ endsection()
section("it should fail to clone an invalid Git repository")
file(REMOVE_RECURSE repo)

assert_fatal_error(
CALL git_clone https://github.com repo
MESSAGE "Failed to clone 'https://github.com'")
assert_call(git_clone https://github.com repo
EXPECT_ERROR "^Failed to clone 'https://github.com'")

assert(NOT EXISTS repo)
endsection()