Skip to content

Commit

Permalink
feat: add support to specify test definitions with list value (#294)
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 22, 2024
1 parent ef372c9 commit 4f72109
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions cmake/Assertion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function(add_cmake_script_test)
if(NOT DEFINITION MATCHES =)
set(DEFINITION "${DEFINITION}=${${DEFINITION}}")
endif()
string(REPLACE ";" "\;" DEFINITION "${DEFINITION}")
list(APPEND TEST_COMMAND -D "${DEFINITION}")
endforeach()
list(APPEND TEST_COMMAND -P "${ARG_FILE}")
Expand Down
8 changes: 4 additions & 4 deletions test/test_add_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ endsection()
section("it should create a new test with predefined variables")
file(WRITE project/test.cmake
"include(\"${ASSERTION_LIST_FILE}\")\n"
"assert(FOO STREQUAL foo)\n"
"assert(BAR STREQUAL barbar)\n"
"assert(FOO STREQUAL \"foo;foo\")\n"
"assert(BAR STREQUAL \"bar;bar\")\n"
"assert(BAZ STREQUAL baz)\n")

file(WRITE project/CMakeLists.txt ${CMAKELISTS_HEADER}
"set(CMAKE_SCRIPT_TEST_DEFINITIONS FOO=foo BAR=bar)\n"
"set(BAR barbar)\n"
"set(CMAKE_SCRIPT_TEST_DEFINITIONS \"FOO=foo\;foo\" BAR=bar)\n"
"set(BAR bar bar)\n"
"add_cmake_script_test(test.cmake DEFINITIONS BAR BAZ=baz)\n")

assert_execute_process("${CMAKE_COMMAND}" --fresh -S project -B project/build)
Expand Down

0 comments on commit 4f72109

Please sign in to comment.