diff --git a/CMakeLists.txt b/CMakeLists.txt index 034d05d..9fcc0bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,11 @@ if(ASSERT_ENABLE_TESTS) NAME "internal assertion message formatting" COMMAND "${CMAKE_COMMAND}" -P ${CMAKE_CURRENT_SOURCE_DIR}/test/InternalFormatMessage.cmake) + + add_test( + NAME "section creation" + COMMAND "${CMAKE_COMMAND}" + -P ${CMAKE_CURRENT_SOURCE_DIR}/test/SectionCreation.cmake) endif() if(ASSERT_ENABLE_INSTALL) diff --git a/cmake/Assertion.cmake b/cmake/Assertion.cmake index ed85e14..6b6fd60 100644 --- a/cmake/Assertion.cmake +++ b/cmake/Assertion.cmake @@ -259,6 +259,7 @@ endfunction() # macro to end the test section. macro(section NAME) message(CHECK_START "${NAME}") + list(APPEND CMAKE_MESSAGE_INDENT " ") endmacro() # Ends the current test section. @@ -267,5 +268,6 @@ endmacro() # # This macro ends the current test section and marks it as passed. macro(endsection) + list(POP_BACK CMAKE_MESSAGE_INDENT) message(CHECK_PASS passed) endmacro() diff --git a/test/SectionCreation.cmake b/test/SectionCreation.cmake new file mode 100644 index 0000000..eb5fa3c --- /dev/null +++ b/test/SectionCreation.cmake @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.5) + +find_package(Assertion REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR}/../cmake) + +section("first section") + assert(CMAKE_MESSAGE_INDENT STREQUAL " ") + + section("second section") + assert(CMAKE_MESSAGE_INDENT STREQUAL " ; ") + endsection() + + assert(CMAKE_MESSAGE_INDENT STREQUAL " ") +endsection()