diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index 4e50e93c4..127266aad 100644 --- a/test/core/CMakeLists.txt +++ b/test/core/CMakeLists.txt @@ -49,7 +49,7 @@ TRIBITS_ADD_ADVANCED_TEST( TestingFunctionMacro_UnitTests -D${PROJECT_NAME}_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} -P "${CMAKE_CURRENT_SOURCE_DIR}/TestingFunctionMacro_UnitTests.cmake" PASS_REGULAR_EXPRESSION_ALL - "Final UnitTests Result: num_run = 544" + "Final UnitTests Result: num_run = 550" "Final UnitTests Result: PASSED" ) diff --git a/test/core/TestingFunctionMacro_UnitTests.cmake b/test/core/TestingFunctionMacro_UnitTests.cmake index 311fb2d24..a68e70ef0 100644 --- a/test/core/TestingFunctionMacro_UnitTests.cmake +++ b/test/core/TestingFunctionMacro_UnitTests.cmake @@ -58,6 +58,7 @@ INCLUDE(TribitsStripQuotesFromStr) INCLUDE(TribitsStandardizePaths) INCLUDE(TribitsGetVersionDate) INCLUDE(TribitsTplFindIncludeDirsAndLibraries) +INCLUDE(TribitsReportInvalidTribitsUsage) INCLUDE(UnitTestHelpers) INCLUDE(GlobalSet) INCLUDE(GlobalNullSet) @@ -556,6 +557,59 @@ FUNCTION(UNITTEST_TRIBITS_TPL_ALLOW_PRE_FIND_PACKAGE) ENDFUNCTION() +FUNCTION(UNITTEST_TRIBITS_REPORT_INVALID_TRIBITS_USAGE) + + MESSAGE("\n***") + MESSAGE("*** Testing TRIBITS_REPORT_INVALID_TRIBITS_USAGE()") + MESSAGE("***\n") + + SET(MESSAGE_WRAPPER_UNIT_TEST_MODE TRUE) + SET(PROJECT_NAME TRITU_PROJECT) + + MESSAGE("TRIBITS_REPORT_INVALID_TRIBITS_USAGE(): Default (FATAL_ERROR)") + GLOBAL_SET(MESSAGE_WRAPPER_INPUT) + TRIBITS_REPORT_INVALID_TRIBITS_USAGE("Something went" " very wrong" " I think 1!") + UNITTEST_COMPARE_CONST(MESSAGE_WRAPPER_INPUT + "FATAL_ERROR;Something went; very wrong; I think 1!") + + MESSAGE("TRIBITS_REPORT_INVALID_TRIBITS_USAGE(): FATAL_ERROR") + GLOBAL_SET(MESSAGE_WRAPPER_INPUT) + SET(${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE FATAL_ERROR) + TRIBITS_REPORT_INVALID_TRIBITS_USAGE("Something went" " very wrong" " I think 2!") + UNITTEST_COMPARE_CONST(MESSAGE_WRAPPER_INPUT + "FATAL_ERROR;Something went; very wrong; I think 2!") + + MESSAGE("TRIBITS_REPORT_INVALID_TRIBITS_USAGE(): SEND_ERROR") + GLOBAL_SET(MESSAGE_WRAPPER_INPUT) + SET(${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE SEND_ERROR) + TRIBITS_REPORT_INVALID_TRIBITS_USAGE("Something went very wrong I think 3!") + UNITTEST_COMPARE_CONST(MESSAGE_WRAPPER_INPUT + "SEND_ERROR;Something went very wrong I think 3!") + + MESSAGE("TRIBITS_REPORT_INVALID_TRIBITS_USAGE(): WARNING") + GLOBAL_SET(MESSAGE_WRAPPER_INPUT) + SET(${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE WARNING) + TRIBITS_REPORT_INVALID_TRIBITS_USAGE("Something went very wrong I think 4!") + UNITTEST_COMPARE_CONST(MESSAGE_WRAPPER_INPUT + "WARNING;Something went very wrong I think 4!") + + MESSAGE("TRIBITS_REPORT_INVALID_TRIBITS_USAGE(): IGNORE") + GLOBAL_SET(MESSAGE_WRAPPER_INPUT) + SET(${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE IGNORE) + TRIBITS_REPORT_INVALID_TRIBITS_USAGE("Something went very wrong I think 5!") + UNITTEST_COMPARE_CONST(MESSAGE_WRAPPER_INPUT + "") + + MESSAGE("TRIBITS_REPORT_INVALID_TRIBITS_USAGE(): INVALID_ARGUMENT") + GLOBAL_SET(MESSAGE_WRAPPER_INPUT) + SET(${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE INVALID_ARGUMENT) + TRIBITS_REPORT_INVALID_TRIBITS_USAGE("Something went very wrong I think 6!") + UNITTEST_COMPARE_CONST(MESSAGE_WRAPPER_INPUT + "FATAL_ERROR;Error, invalid value for; TRITU_PROJECT_ASSERT_CORRECT_TRIBITS_USAGE =; 'INVALID_ARGUMENT'!; Value values include 'FATAL_ERROR', 'SEND_ERROR', 'WARNING', and 'IGNORE'!") + +ENDFUNCTION() + + FUNCTION(UNITEST_TRIBITS_ADD_TEST_BASIC) MESSAGE("\n***") @@ -3590,6 +3644,7 @@ UNITEST_TRIBITS_STRIP_QUOTES_FROM_STR() UNITEST_TRIBITS_GET_VERSION_DATE_FROM_RAW_GIT_COMMIT_UTC_TIME() UNITEST_TRIBITS_GET_RAW_GIT_COMMIT_UTC_TIME() UNITTEST_TRIBITS_TPL_ALLOW_PRE_FIND_PACKAGE() +UNITTEST_TRIBITS_REPORT_INVALID_TRIBITS_USAGE() # Set the default test categories SET(${PROJECT_NAME}_TEST_CATEGORIES NIGHTLY) @@ -3641,4 +3696,4 @@ MESSAGE("*** Determine final result of all unit tests") MESSAGE("***\n") # Pass in the number of expected tests that must pass! -UNITTEST_FINAL_RESULT(544) +UNITTEST_FINAL_RESULT(550) diff --git a/tribits/core/package_arch/TribitsReportInvalidTribitsUsage.cmake b/tribits/core/package_arch/TribitsReportInvalidTribitsUsage.cmake index f61f7b80a..f4bdaaeb7 100644 --- a/tribits/core/package_arch/TribitsReportInvalidTribitsUsage.cmake +++ b/tribits/core/package_arch/TribitsReportInvalidTribitsUsage.cmake @@ -43,6 +43,8 @@ ELSE() SET(__TribitsReportInvalidTribitsUsage_INCLUDED__ TRUE) ENDIF() +INCLUDE(MessageWrapper) + # Called to report incorrect usage # # Usage: @@ -74,12 +76,12 @@ FUNCTION(TRIBITS_REPORT_INVALID_TRIBITS_USAGE) ELSEIF (${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE STREQUAL "IGNORE") SET(PRINT_ERR_MSG) ELSE() - MESSAGE(FATAL_ERROR "Error, invalid value for" + MESSAGE_WRAPPER(FATAL_ERROR "Error, invalid value for" " ${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE =" " '${${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE}'!" " Value values include 'FATAL_ERROR', 'SEND_ERROR', 'WARNING', and 'IGNORE'!") ENDIF() IF (PRINT_ERR_MSG) - MESSAGE(${PRINT_ERR_MSG} ${ARGN}) + MESSAGE_WRAPPER(${PRINT_ERR_MSG} ${ARGN}) ENDIF() ENDFUNCTION()