Skip to content

Commit

Permalink
Add check for package-with-subpackage commands in packages without su…
Browse files Browse the repository at this point in the history
…bpackages (#200)

The SCOREC packages was generating strange configure errors when it was trying
to call commands for a package with subpackages but did not have any
subpackages.  The error message was terrible in this case.  I added a new
check and new test case to produce a good error message.  Hopefully that would
have made it easier to fix the error in the SCOREC package.

I also improved the error message to mention that you can call
TRIBITS_PACKAGE_DECL() and TRIBITS_PACKAGE_DEF() or TRIBITS_PACKAGE() before
TRIBITS_PACKAGE_POSTPROCESS().  That hopefully is a little better error
message?  In any case, I think we need to go over these error messages a
little more to make sure they provide the best info to the developer.

Build/Test Cases Summary
Enabled Packages:
Enabled all Packages
0) MPI_DEBUG => passed: passed=263,notpassed=0 (0.72 min)
1) SERIAL_RELEASE => passed: passed=263,notpassed=0 (0.59 min)
2) MPI_DEBUG_CMAKE-3.6.2 => passed: passed=284,notpassed=0 (0.56 min)
3) SERIAL_RELEASE_CMAKE-3.6.2 => passed: passed=284,notpassed=0 (0.54 min)
  • Loading branch information
bartlettroscoe committed Nov 7, 2017
1 parent 940eafe commit dcc2956
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 17 deletions.
25 changes: 20 additions & 5 deletions test/core/ExamplesUnitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3096,7 +3096,6 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_PkgWithUserErrors_PACKAGE_INIT
TribitsExampleProject/.

TEST_2
MESSAGE "Configure PkgWithUserErrors"
CMND ${CMAKE_COMMAND}
ARGS
${TribitsExampleProject_COMMON_CONFIG_ARGS}
Expand All @@ -3114,7 +3113,6 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_PkgWithUserErrors_PACKAGE_INIT
ALWAYS_FAIL_ON_ZERO_RETURN

TEST_3
MESSAGE "Configure PkgWithUserErrors"
CMND ${CMAKE_COMMAND}
ARGS
${TribitsExampleProject_COMMON_CONFIG_ARGS}
Expand All @@ -3133,7 +3131,6 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_PkgWithUserErrors_PACKAGE_INIT
ALWAYS_FAIL_ON_ZERO_RETURN

TEST_4
MESSAGE "Configure PkgWithUserErrors"
CMND ${CMAKE_COMMAND}
ARGS
${TribitsExampleProject_COMMON_CONFIG_ARGS}
Expand All @@ -3148,12 +3145,12 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_PkgWithUserErrors_PACKAGE_INIT
-DPkgWithUserErrors_POSTPROCESS_with_no_package_init=TRUE
TribitsExampleProject
PASS_REGULAR_EXPRESSION_ALL
"Must call TRIBITS_PACKAGE[(][)] before TRIBITS_PACKAGE_POSTPROCESS[(][)]"
"Must call TRIBITS_PACKAGE[(][)] or TRIBITS_PACKAGE_DEF[(][)]"
"TRIBITS_PACKAGE_POSTPROCESS[(][)]"
"Configuring incomplete, errors occurred!"
ALWAYS_FAIL_ON_ZERO_RETURN

TEST_5
MESSAGE "Configure PkgWithUserErrors"
CMND ${CMAKE_COMMAND}
ARGS
${TribitsExampleProject_COMMON_CONFIG_ARGS}
Expand All @@ -3173,6 +3170,24 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_PkgWithUserErrors_PACKAGE_INIT
"Configuring incomplete, errors occurred!"
ALWAYS_FAIL_ON_ZERO_RETURN

TEST_6
CMND ${CMAKE_COMMAND}
ARGS
${TribitsExampleProject_COMMON_CONFIG_ARGS}
-DTribitsExProj_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR}
-DTribitsExProj_ENABLE_Fortran=OFF
-DTribitsExProj_EXTRA_REPOSITORIES=PkgWithUserErrors
-DTribitsExProj_ENABLE_PkgWithUserErrors=ON
-DTribitsExProj_ENABLE_TESTS=ON
-DPkgWithUserErrors_multiple_calls_to_PACKAGE=FALSE
-DPkgWithUserErrors_using_package_with_subpackage_commands=TRUE
TribitsExampleProject
PASS_REGULAR_EXPRESSION_ALL
"The TriBITS Package 'PkgWithUserErrors' does not have any subpackages[.]"
"Therefore, you are not allowed to call TRIBITS_PROCESS_SUBPACKAGES[(][)]!"
"Configuring incomplete, errors occurred!"
ALWAYS_FAIL_ON_ZERO_RETURN

)

TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_PkgWithUserErrors_AFTER_POSTPROCESS
Expand Down
9 changes: 9 additions & 0 deletions test/core/ExamplesUnitTests/PkgWithUserErrors/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,12 @@ IF(${PACKAGE_NAME}_UNPARSED_ARGS_ADD_EXECUTABLE)
TRIBITS_ADD_TEST_DIRECTORIES(test)
TRIBITS_PACKAGE_POSTPROCESS()
ENDIF()


IF (${PACKAGE_NAME}_using_package_with_subpackage_commands)
MESSAGE("Using package with subpackage commands in error")
TRIBITS_PACKAGE_DECL(PkgWithUserErrors)
TRIBITS_PROCESS_SUBPACKAGES()
TRIBITS_PACKAGE_DEF()
TRIBITS_PACKAGE_POSTPROCESS()
ENDIF()
41 changes: 29 additions & 12 deletions tribits/core/package_arch/TribitsPackageMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ MACRO(TRIBITS_PACKAGE_DEF)
SET(PACKAGE_NAME ${PARENT_PACKAGE_NAME})

# check that this is not called morethan once in a package
IF(${PACKAGE_NAME}_TRIBITS_PACKAGE_DEF_CALLED)
IF (${PACKAGE_NAME}_TRIBITS_PACKAGE_DEF_CALLED)
MESSAGE(FATAL_ERROR "TRIBITS_PACKAGE_DEF was called more than once in"
"${CURRENT_SUBPACKAGE_CMAKELIST_FILE}"
)
Expand Down Expand Up @@ -756,13 +756,18 @@ MACRO(TRIBITS_PACKAGE_POSTPROCESS)

ELSE()

# This is a package without subpackages
# This is a package without subpackages

IF(NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_CALLED)
MESSAGE(FATAL_ERROR "Must call TRIBITS_PACKAGE() before TRIBITS_PACKAGE_POSTPROCESS()"
"\n at the top of the file: "
"\n ${TRIBITS_PACKAGE_CMAKELIST_FILE}"
IF (
(NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_CALLED)
AND
(NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_DEF_CALLED)
)
MESSAGE(FATAL_ERROR "Must call TRIBITS_PACKAGE() or TRIBITS_PACKAGE_DEF() before"
" TRIBITS_PACKAGE_POSTPROCESS()"
" at the top of the file:\n"
" ${TRIBITS_PACKAGE_CMAKELIST_FILE}"
)
ENDIF()

ENDIF()
Expand Down Expand Up @@ -826,16 +831,28 @@ MACRO(TRIBITS_PROCESS_SUBPACKAGES)
" ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}")
ENDIF()

IF(${PACKAGE_NAME}_TRIBITS_PACKAGE_POSTPROCESS_CALLED)
MESSAGE(FATAL_ERROR "Must call TRIBITS_PROCESS_SUBPACKAGES() before TRIBITS_PACKAGE_POSTPROCESS() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}")
IF (${PACKAGE_NAME}_TRIBITS_PACKAGE_POSTPROCESS_CALLED)
MESSAGE(FATAL_ERROR
"Must call TRIBITS_PROCESS_SUBPACKAGES() before TRIBITS_PACKAGE_POSTPROCESS()"
" in ${TRIBITS_PACKAGE_CMAKELIST_FILE}")
ENDIF()

IF (NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_DECL_CALLED)
MESSAGE(FATAL_ERROR
"Must call TRIBITS_PACKAGE_DECL() before TRIBITS_PROCESS_SUBPACKAGES()"
"in ${TRIBITS_PACKAGE_CMAKELIST_FILE}")
ENDIF()

IF(NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_DECL_CALLED)
MESSAGE(FATAL_ERROR "Must call TRIBITS_PACKAGE_DECL() before TRIBITS_PROCESS_SUBPACKAGES() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}")
IF (${PACKAGE_NAME}_TRIBITS_PACKAGE_DEF_CALLED)
MESSAGE(FATAL_ERROR
"Must call TRIBITS_PACKAGE_DEF() after TRIBITS_PROCESS_SUBPACKAGES()"
" in ${TRIBITS_PACKAGE_CMAKELIST_FILE}")
ENDIF()

IF(${PACKAGE_NAME}_TRIBITS_PACKAGE_DEF_CALLED)
MESSAGE(FATAL_ERROR "Must call TRIBITS_PACKAGE_DEF() after TRIBITS_PROCESS_SUBPACKAGES() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}")
IF (NOT ${PARENT_PACKAGE_NAME}_SUBPACKAGES)
MESSAGE(FATAL_ERROR
"The TriBITS Package '${PACKAGE_NAME}' does not have any subpackages."
" Therefore, you are not allowed to call TRIBITS_PROCESS_SUBPACKAGES()!")
ENDIF()

SET(SUBPACKAGE_IDX 0)
Expand Down

0 comments on commit dcc2956

Please sign in to comment.