Skip to content

Commit

Permalink
Merge pull request #425 from bartlettroscoe/299-refactor-cleanup-2
Browse files Browse the repository at this point in the history
Some refactorings I noticed while working on #299
  • Loading branch information
bartlettroscoe authored Oct 30, 2021
2 parents bc14759 + 6c4f53a commit 7fca4cd
Show file tree
Hide file tree
Showing 21 changed files with 162 additions and 96 deletions.
5 changes: 1 addition & 4 deletions test/core/CompilerOptions_UnitTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -807,10 +807,7 @@ endfunction()
#
#####################################################################

# Assume that all unit tests will pass by default
global_set(UNITTEST_OVERALL_PASS TRUE)
global_set(UNITTEST_OVERALL_NUMPASSED 0)
global_set(UNITTEST_OVERALL_NUMRUN 0)
unittest_initialize_vars()

# Set common/base options
set(PROJECT_NAME "DummyProject")
Expand Down
5 changes: 1 addition & 4 deletions test/core/TestingFunctionMacro_UnitTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4360,10 +4360,7 @@ endfunction()
set(${PROJECT_NAME}_HOSTNAME testhost.nowhere.com)
set(CMAKE_HOST_SYSTEM_NAME UnspecifiedHostSystemName)

# Assume that all unit tests will pass by default
global_set(UNITTEST_OVERALL_PASS TRUE)
global_set(UNITTEST_OVERALL_NUMPASSED 0)
global_set(UNITTEST_OVERALL_NUMRUN 0)
unittest_initialize_vars()

# Set up the tribits_add_test(...) and tribits_add_advanced_test() functions
# for unit test mode.
Expand Down
5 changes: 1 addition & 4 deletions test/core/TribitsAdjustPackageEnables_UnitTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,7 @@ endfunction()
#
#####################################################################

# Assume that all unit tests will pass by default
global_set(UNITTEST_OVERALL_PASS TRUE)
global_set(UNITTEST_OVERALL_NUMPASSED 0)
global_set(UNITTEST_OVERALL_NUMRUN 0)
unittest_initialize_vars()

# A) Test enabled/disable logic
unittest_enable_no_packages()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,7 @@ endfunction()
#
#####################################################################

# Assume that all unit tests will pass by default
global_set(UNITTEST_OVERALL_PASS TRUE)
global_set(UNITTEST_OVERALL_NUMPASSED 0)
global_set(UNITTEST_OVERALL_NUMRUN 0)
unittest_initialize_vars()

# Set common/base options
set(PROJECT_NAME "DummyProject")
Expand Down
5 changes: 1 addition & 4 deletions test/core/TribitsProcessPackagesAndDirsLists_UnitTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,7 @@ endfunction()
#
#####################################################################

# Assume that all unit tests will pass by default
global_set(UNITTEST_OVERALL_PASS TRUE)
global_set(UNITTEST_OVERALL_NUMPASSED 0)
global_set(UNITTEST_OVERALL_NUMRUN 0)
unittest_initialize_vars()

# Set common/base options
set(PROJECT_NAME "DummyProject")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -738,10 +738,7 @@ endfunction()
#
################################################################################

# Assume that all unit tests will pass by default
global_set(UNITTEST_OVERALL_PASS TRUE)
global_set(UNITTEST_OVERALL_NUMPASSED 0)
global_set(UNITTEST_OVERALL_NUMRUN 0)
unittest_initialize_vars()

# Unit tests for code macros that are used to declare/define dependencies
unitest_tribits_define_repository_packages_dirs_classifications_empty()
Expand Down
5 changes: 1 addition & 4 deletions test/core/TribitsWriteClientExportFiles_UnitTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,7 @@ endfunction()
#
#####################################################################

# Assume that all unit tests will pass by default
global_set(UNITTEST_OVERALL_PASS TRUE)
global_set(UNITTEST_OVERALL_NUMPASSED 0)
global_set(UNITTEST_OVERALL_NUMRUN 0)
unittest_initialize_vars()

#
# Run the unit tests
Expand Down
5 changes: 1 addition & 4 deletions test/ctest_driver/CTestDriverUnitTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,7 @@ endfunction()
# Execute the unit tests
#

# Assume that all unit tests will pass by default
global_set(UNITTEST_OVERALL_PASS TRUE)
global_set(UNITTEST_OVERALL_NUMPASSED 0)
global_set(UNITTEST_OVERALL_NUMRUN 0)
unittest_initialize_vars()

# Run the unit test functions
unittest_tribits_read_ctest_tag_file()
Expand Down
44 changes: 22 additions & 22 deletions tribits/core/package_arch/TribitsAddAdvancedTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ function(tribits_add_advanced_test TEST_NAME_IN)

set(TEST_SCRIPT_STR "")

append_string_var( TEST_SCRIPT_STR
string(APPEND TEST_SCRIPT_STR
"\n"
"#\n"
"# This is a CMake script and must be run as \"cmake -P <SCRIPT_NAME>\"\n"
Expand Down Expand Up @@ -1187,7 +1187,7 @@ function(tribits_add_advanced_test TEST_NAME_IN)
string(REPLACE ";" "," FILES_TO_COPY_COMMA_SEP
"${FILES_TO_COPY_COMMA_SEP}" )
# NOTE: Above, we have to replace ';' with ',' or the lower commands
# append_string_var() will replace ';' with ''. This is *not* what we
# string(APPEND ) will replace ';' with ''. This is *not* what we
# want. In DriveAdvancedTest.cmake, we will replace the ',' with ';'
# again :-)

Expand Down Expand Up @@ -1234,7 +1234,7 @@ function(tribits_add_advanced_test TEST_NAME_IN)

# Write the vars for COPY_FILES_TO_TEST_DIR

append_string_var( TEST_SCRIPT_STR
string(APPEND TEST_SCRIPT_STR
"\n"
"set( TEST_${TEST_CMND_IDX}_COPY_FILES_TO_TEST_DIR"
" \"${FILES_TO_COPY_COMMA_SEP}\")\n"
Expand All @@ -1244,13 +1244,13 @@ function(tribits_add_advanced_test TEST_NAME_IN)
"${TEST_CMND_STR}" )
endif()

append_string_var( TEST_SCRIPT_STR
string(APPEND TEST_SCRIPT_STR
"\n"
"set( TEST_${TEST_CMND_IDX}_SOURCE_DIR"
" \"${COPY_FILES_TO_TEST_DIR_SOURCE_DIR}\")\n"
)

append_string_var( TEST_SCRIPT_STR
string(APPEND TEST_SCRIPT_STR
"\n"
"set( TEST_${TEST_CMND_IDX}_DEST_DIR"
" \"${COPY_FILES_TO_TEST_DIR_DEST_DIR}\")\n"
Expand All @@ -1263,7 +1263,7 @@ function(tribits_add_advanced_test TEST_NAME_IN)
tribits_join_exec_process_set_args( TEST_CMND_STR "${TEST_CMND_ARRAY}" )
#print_var(TEST_CMND_STR)

append_string_var( TEST_SCRIPT_STR
string(APPEND TEST_SCRIPT_STR
"\n"
"set( TEST_${TEST_CMND_IDX}_CMND ${TEST_CMND_STR} )\n"
)
Expand All @@ -1275,7 +1275,7 @@ function(tribits_add_advanced_test TEST_NAME_IN)
endif()

if (PARSE_MESSAGE)
append_string_var( TEST_SCRIPT_STR
string(APPEND TEST_SCRIPT_STR
"\n"
"set( TEST_${TEST_CMND_IDX}_MESSAGE \"${PARSE_MESSAGE}\" )\n"
)
Expand All @@ -1285,25 +1285,25 @@ function(tribits_add_advanced_test TEST_NAME_IN)
if ("${PARSE_WORKING_DIRECTORY}" STREQUAL "TEST_NAME")
set(PARSE_WORKING_DIRECTORY ${TEST_NAME})
endif()
append_string_var( TEST_SCRIPT_STR
string(APPEND TEST_SCRIPT_STR
"\n"
"set( TEST_${TEST_CMND_IDX}_WORKING_DIRECTORY \"${PARSE_WORKING_DIRECTORY}\" )\n"
)
append_string_var( TEST_SCRIPT_STR
string(APPEND TEST_SCRIPT_STR
"\n"
"set( TEST_${TEST_CMND_IDX}_SKIP_CLEAN_WORKING_DIRECTORY ${PARSE_SKIP_CLEAN_WORKING_DIRECTORY} )\n"
)
endif()

if (PARSE_OUTPUT_FILE)
append_string_var( TEST_SCRIPT_STR
string(APPEND TEST_SCRIPT_STR
"\n"
"set( TEST_${TEST_CMND_IDX}_OUTPUT_FILE \"${PARSE_OUTPUT_FILE}\" )\n"
)
endif()

if (PARSE_NO_ECHO_OUTPUT)
append_string_var( TEST_SCRIPT_STR
string(APPEND TEST_SCRIPT_STR
"\n"
"set( TEST_${TEST_CMND_IDX}_NO_ECHO_OUTPUT \"${PARSE_NO_ECHO_OUTPUT}\" )\n"
)
Expand All @@ -1312,58 +1312,58 @@ function(tribits_add_advanced_test TEST_NAME_IN)
# Set up pass/fail

if (PARSE_PASS_ANY)
append_string_var( TEST_SCRIPT_STR
string(APPEND TEST_SCRIPT_STR
"\n"
"set( TEST_${TEST_CMND_IDX}_PASS_ANY TRUE )\n"
)
elseif (PARSE_STANDARD_PASS_OUTPUT)
append_string_var( TEST_SCRIPT_STR
string(APPEND TEST_SCRIPT_STR
"\n"
"set( TEST_${TEST_CMND_IDX}_PASS_REGULAR_EXPRESSION \"End Result: TEST PASSED\" )\n"
)
elseif (PARSE_PASS_REGULAR_EXPRESSION)
append_string_var( TEST_SCRIPT_STR
string(APPEND TEST_SCRIPT_STR
"\n"
"set( TEST_${TEST_CMND_IDX}_PASS_REGULAR_EXPRESSION \"${PARSE_PASS_REGULAR_EXPRESSION}\" )\n"
)
elseif (PARSE_PASS_REGULAR_EXPRESSION_ALL)
append_string_var( TEST_SCRIPT_STR
string(APPEND TEST_SCRIPT_STR
"\n"
"set( TEST_${TEST_CMND_IDX}_PASS_REGULAR_EXPRESSION_ALL "
)
foreach(REGEX_STR ${PARSE_PASS_REGULAR_EXPRESSION_ALL})
append_string_var( TEST_SCRIPT_STR
string(APPEND TEST_SCRIPT_STR
"\"${REGEX_STR}\" "
)
endforeach()
append_string_var( TEST_SCRIPT_STR
string(APPEND TEST_SCRIPT_STR
")\n"
)
endif()

if (PARSE_FAIL_REGULAR_EXPRESSION)
append_string_var( TEST_SCRIPT_STR
string(APPEND TEST_SCRIPT_STR
"\n"
"set( TEST_${TEST_CMND_IDX}_FAIL_REGULAR_EXPRESSION \"${PARSE_FAIL_REGULAR_EXPRESSION}\" )\n"
)
endif()

if (PARSE_ALWAYS_FAIL_ON_NONZERO_RETURN)
append_string_var( TEST_SCRIPT_STR
string(APPEND TEST_SCRIPT_STR
"\n"
"set( TEST_${TEST_CMND_IDX}_ALWAYS_FAIL_ON_NONZERO_RETURN TRUE )\n"
)
endif()

if (PARSE_ALWAYS_FAIL_ON_ZERO_RETURN)
append_string_var( TEST_SCRIPT_STR
string(APPEND TEST_SCRIPT_STR
"\n"
"set( TEST_${TEST_CMND_IDX}_ALWAYS_FAIL_ON_ZERO_RETURN TRUE )\n"
)
endif()

if (PARSE_WILL_FAIL)
append_string_var( TEST_SCRIPT_STR
string(APPEND TEST_SCRIPT_STR
"\n"
"set( TEST_${TEST_CMND_IDX}_WILL_FAIL TRUE )\n"
)
Expand Down Expand Up @@ -1451,7 +1451,7 @@ function(tribits_add_advanced_test TEST_NAME_IN)
# F.2) Write the cmake -P script
#

append_string_var( TEST_SCRIPT_STR
string(APPEND TEST_SCRIPT_STR
"\n"
"set(PROJECT_NAME ${PROJECT_NAME})\n"
"\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ function(tribits_create_client_template_headers BASE_DIR)

# Create the client header file
set(CLIENT_HEADER_STR "")
append_string_var(CLIENT_HEADER_STR
string(APPEND CLIENT_HEADER_STR
"#include \"${DECL_HEADER_BASE}${${PARENT_PACKAGE_NAME}_TEMPLATE_DECL_EXT}\"\n"
)
if (HAVE_${PARENT_PACKAGE_NAME_UC}_EXPLICIT_INSTANTIATION)
set(TEMPLATE_INSTANT_TYPE_NAME "explicit instantiation")
else()
set(TEMPLATE_INSTANT_TYPE_NAME "implicit instantiation")
append_string_var(CLIENT_HEADER_STR
string(APPEND CLIENT_HEADER_STR
"#include \"${DECL_HEADER_BASE}${${PARENT_PACKAGE_NAME}_TEMPLATE_DEF_EXT}\"\n"
)
endif()
Expand All @@ -161,7 +161,7 @@ function(tribits_create_client_template_headers BASE_DIR)
# Create the SIERRA BJAM version of the header file
foreach(OUTPUT_DIR ${PARSE_ADDITIONAL_OUTPUT_DIRS})
set(EXTERNAL_CLIENT_HEADER_STR "")
append_string_var(EXTERNAL_CLIENT_HEADER_STR
string(APPEND EXTERNAL_CLIENT_HEADER_STR
"#include \"${DECL_HEADER_BASE}${${PARENT_PACKAGE_NAME}_TEMPLATE_DECL_EXT}\"\n"
"#ifndef HAVE_${PARENT_PACKAGE_NAME_UC}_EXPLICIT_INSTANTIATION\n"
"# include \"${DECL_HEADER_BASE}${${PARENT_PACKAGE_NAME}_TEMPLATE_DEF_EXT}\"\n"
Expand Down
6 changes: 3 additions & 3 deletions tribits/core/package_arch/TribitsGlobalMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ include(TribitsTplDeclareLibraries) # Deprecated
#
macro(tribits_assert_and_setup_project_and_static_system_vars)

append_string_var(IN_SOURCE_ERROR_COMMON_MSG
string(APPEND IN_SOURCE_ERROR_COMMON_MSG
"\nYou must now run something like:\n"
" $ cd ${CMAKE_CURRENT_SOURCE_DIR}/\n"
" $ rm -r CMakeCache.txt CMakeFiles/"
Expand Down Expand Up @@ -1312,7 +1312,7 @@ function(tribits_generate_repo_version_file_string PROJECT_REPO_VERSION_FILE_ST
tribits_generate_single_repo_version_string(
${CMAKE_CURRENT_SOURCE_DIR}
SINGLE_REPO_VERSION)
append_string_var(REPO_VERSION_FILE_STR
string(APPEND REPO_VERSION_FILE_STR
"*** Base Git Repo: ${PROJECT_NAME}\n"
"${SINGLE_REPO_VERSION}\n" )

Expand All @@ -1336,7 +1336,7 @@ function(tribits_generate_repo_version_file_string PROJECT_REPO_VERSION_FILE_ST
tribits_generate_single_repo_version_string(
"${CMAKE_CURRENT_SOURCE_DIR}/${EXTRAREPO_DIR}"
SINGLE_REPO_VERSION)
append_string_var(REPO_VERSION_FILE_STR
string(APPEND REPO_VERSION_FILE_STR
"*** Git Repo: ${EXTRAREPO_DIR}\n"
"${SINGLE_REPO_VERSION}\n" )

Expand Down
2 changes: 1 addition & 1 deletion tribits/core/package_arch/TribitsLibraryMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function(tribits_configure_file PACKAGE_NAME_CONFIG_FILE)
endif()

if (${PARENT_PACKAGE_NAME}_HIDE_DEPRECATED_CODE)
append_string_var(${PARENT_PACKAGE_NAME_UC}_DEPRECATED_DECLARATIONS
string(APPEND ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_DECLARATIONS
"\n#define ${PARENT_PACKAGE_NAME_UC}_HIDE_DEPRECATED_CODE")
endif()

Expand Down
6 changes: 3 additions & 3 deletions tribits/core/package_arch/TribitsProcessEnabledTpl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ function(tribits_process_enabled_tpl TPL_NAME)
# Setup the processing string
set(PROCESSING_MSG_STRING "Processing enabled TPL: ${TPL_NAME} (")
if (TPL_${TPL_NAME}_ENABLING_PKG)
append_string_var(PROCESSING_MSG_STRING
string(APPEND PROCESSING_MSG_STRING
"enabled by ${TPL_${TPL_NAME}_ENABLING_PKG}," )
else()
append_string_var(PROCESSING_MSG_STRING
string(APPEND PROCESSING_MSG_STRING
"enabled explicitly," )
endif()
append_string_var(PROCESSING_MSG_STRING
string(APPEND PROCESSING_MSG_STRING
" disable with -DTPL_ENABLE_${TPL_NAME}=OFF)" )

# Print the processing header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@
# ************************************************************************
# @HEADER

if (__TribitsReportInvalidTribitsUsage_INCLUDED__)
return()
else()
set(__TribitsReportInvalidTribitsUsage_INCLUDED__ TRUE)
endif()
include_guard()

include(MessageWrapper)

Expand Down
Loading

0 comments on commit 7fca4cd

Please sign in to comment.