Skip to content
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
5 changes: 3 additions & 2 deletions cmake/cmake_test/asserts/asserts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ include(cmake_test/asserts/defined)
include(cmake_test/asserts/equal)
include(cmake_test/asserts/file_contains)
include(cmake_test/asserts/file_exists)
include(cmake_test/asserts/list)
include(cmake_test/asserts/library_exists)
include(cmake_test/asserts/list)
include(cmake_test/asserts/prints)
include(cmake_test/asserts/string)
include(cmake_test/asserts/target_exists)
include(cmake_test/asserts/target_has_property)
include(cmake_test/asserts/true_false)
include(cmake_test/asserts/prints)
1 change: 0 additions & 1 deletion tests/cmake_test/asserts/library_exists.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
include(cmake_test/cmake_test)
cmake_policy(SET CMP0002 OLD) #Allow duplicate targets by overriding, needed for multiple tests that work with the same target

ct_add_test(NAME assert_library_exists)
function(${assert_library_exists})
Expand Down
20 changes: 12 additions & 8 deletions tests/cmake_test/asserts/target_exists.cmake
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
include(cmake_test/cmake_test)
cmake_policy(SET CMP0002 OLD) #Allow duplicate targets by overriding, needed for multiple tests that work with the same target


ct_add_test(NAME assert_target_exists)
function(${assert_target_exists})
include(cmake_test/asserts/target_exists)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/a.c" "")
add_library(my_lib "${CMAKE_CURRENT_BINARY_DIR}/a.c")

ct_add_section(NAME test_target_exists)
function(${test_target_exists})
add_custom_target(my_target ALL)
ct_assert_target_exists(my_target)
set(target_name "target_${test_target_exists}")

file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/a.c" "")
add_library("${target_name}" "${CMAKE_CURRENT_BINARY_DIR}/a.c")
ct_assert_target_exists("${target_name}")
endfunction()

ct_add_section(NAME test_target_does_not_exist EXPECTFAIL)
function(${test_target_does_not_exist})
set(target_name "target_${test_target_does_not_exists}")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/a.c" "")
add_library("${target_name}" "${CMAKE_CURRENT_BINARY_DIR}/a.c")
ct_assert_target_exists(non_existant_target)
endfunction()

endfunction()

ct_add_test(NAME assert_target_does_not_exist)
Expand All @@ -26,8 +29,9 @@ function(${assert_target_does_not_exist})

ct_add_section(NAME test_target_exists EXPECTFAIL)
function(${test_target_exists})
add_custom_target(my_target ALL)
ct_assert_target_does_not_exist(my_target)
set(target_name "target_${test_target_exist}")
add_custom_target("${target_name}" ALL)
ct_assert_target_does_not_exist("${target_name}")
endfunction()

ct_add_section(NAME test_target_does_not_exist)
Expand Down
41 changes: 13 additions & 28 deletions tests/cmake_test/asserts/target_has_property.cmake
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
include(cmake_test/cmake_test)
cmake_policy(SET CMP0002 OLD) #Allow duplicate targets by overriding, needed for multiple tests that work with the same target

ct_add_test(NAME assert_target_has_property)
function(${assert_target_has_property})
include(cmake_test/asserts/target_has_property)

ct_add_section(NAME test_target_exists)
function(${test_target_exists})
set(target_name "target_${assert_target_has_property}")
# Create target and add property
add_custom_target(my_target ALL)
ct_assert_target_exists(my_target)
set_target_properties(
my_target
PROPERTIES property_1 value_1
)

ct_add_section(NAME test_target_has_property)
function(${test_target_has_property})
ct_assert_target_has_property(my_target property_1)
endfunction()
add_custom_target("${target_name}" ALL)
ct_assert_target_exists("${target_name}")
set_target_properties("${target_name}" PROPERTIES property_1 value_1)

ct_add_section(NAME test_target_does_not_have_property EXPECTFAIL)
function(${test_target_does_not_have_property})
ct_assert_target_has_property(my_target non_existant_property)
endfunction()
ct_assert_target_has_property("${target_name}" property_1)
endfunction()

ct_add_section(NAME test_target_does_not_exist EXPECTFAIL)
Expand All @@ -38,23 +27,19 @@ function(${assert_target_does_not_have_property})

ct_add_section(NAME test_target_exists)
function(${test_target_exists})
set(target_name "target_${test_target_exists}")

# Create target and add property
add_custom_target(my_target ALL)
ct_assert_target_exists(my_target)
add_custom_target("${target_name}" ALL)
ct_assert_target_exists("${target_name}")
set_target_properties(
my_target
"${target_name}"
PROPERTIES property_1 value_1
)

ct_add_section(NAME test_target_has_property EXPECTFAIL)
function(${test_target_has_property})
ct_assert_target_does_not_have_property(my_target property_1)
endfunction()

ct_add_section(NAME test_target_does_not_have_property)
function(${test_target_does_not_have_property})
ct_assert_target_does_not_have_property(my_target non_existant_property)
endfunction()
ct_assert_target_does_not_have_property(
"${target_name}" non_existant_property
)
endfunction()

ct_add_section(NAME test_target_does_not_exist EXPECTFAIL)
Expand Down
Loading