Skip to content

Commit

Permalink
Merge branch 'user-error-checking-200' (#200)
Browse files Browse the repository at this point in the history
Build/Test Cases Summary
Enabled Packages:
Enabled all Packages
0) MPI_DEBUG => passed: passed=251,notpassed=0 (0.74 min)
1) SERIAL_RELEASE => passed: passed=251,notpassed=0 (0.70 min)
2) MPI_DEBUG_CMAKE-3.6.2 => passed: passed=272,notpassed=0 (0.83 min)
3) SERIAL_RELEASE_CMAKE-3.6.2 => passed: passed=272,notpassed=0 (0.74 min)
Other local commits for this build/test group: 8d7fb25, 4d988ab, cfb441b
  • Loading branch information
bartlettroscoe committed Aug 11, 2017
2 parents d03fdde + 8d7fb25 commit 43d2603
Show file tree
Hide file tree
Showing 16 changed files with 367 additions and 4 deletions.
216 changes: 216 additions & 0 deletions test/core/ExamplesUnitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2989,3 +2989,219 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleMetaProject
"100% tests passed, 0 tests failed out of"

)


########################################################################
# User error checking tests
########################################################################


TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_PkgWithUserErrors_PASS
OVERALL_WORKING_DIRECTORY TEST_NAME
OVERALL_NUM_MPI_PROCS 1

TEST_0
MESSAGE "Copy TribitsExampleProject so that we can copy in PkgWithUserErrors."
CMND cp
ARGS -r ${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject .

TEST_1
MESSAGE "Copy PkgWithUserErrors to base dir."
CMND cp
ARGS -r ${CMAKE_CURRENT_SOURCE_DIR}/PkgWithUserErrors
TribitsExampleProject/.

TEST_2
MESSAGE "Configure PkgWithUserErrors"
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_ADD_LIBRARY_BEFORE_POST_PROCESS=TRUE
TribitsExampleProject
PASS_REGULAR_EXPRESSION_ALL
"Explicitly enabled packages on input [(]by user[)]: PkgWithUserErrors 1"
"Final set of enabled packages: PkgWithUserErrors 1"
"Processing enabled package: PkgWithUserErrors [(]Libs, Tests, Examples[)]"
"Configuring done"
"Generating done"
ALWAYS_FAIL_ON_NONZERO_RETURN

TEST_3 CMND make
ARGS ${CTEST_BUILD_FLAGS}
PASS_REGULAR_EXPRESSION_ALL
"Built target PkgWithUserErrors_PkgWithUserErrorsTest"
ALWAYS_FAIL_ON_NONZERO_RETURN

TEST_4 CMND ${CMAKE_CTEST_COMMAND} ARGS -VV
PASS_REGULAR_EXPRESSION_ALL
"Test [#]1: PkgWithUserErrors_PkgWithUserErrorsTest[_MPI1]* [.]+ +Passed"
ALWAYS_FAIL_ON_NONZERO_RETURN

)


TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_PkgWithUserErrors_PACKAGE_POST_PROCESS
OVERALL_WORKING_DIRECTORY TEST_NAME
OVERALL_NUM_MPI_PROCS 1

TEST_0
MESSAGE "Copy TribitsExampleProject so that we can copy in PkgWithUserErrors."
CMND cp
ARGS -r ${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject .

TEST_1
MESSAGE "Copy PkgWithUserErrors to base dir."
CMND cp
ARGS -r ${CMAKE_CURRENT_SOURCE_DIR}/PkgWithUserErrors
TribitsExampleProject/.

TEST_2
MESSAGE "Configure PkgWithUserErrors"
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_SKIP_PACKAGE_POST_PROCESS=TRUE
-DPkgWithUserErrors_ADD_LIBRARY_BEFORE_POST_PROCESS=TRUE
TribitsExampleProject
PASS_REGULAR_EXPRESSION_ALL
"Processing enabled package: PkgWithUserErrors [(]Libs, Tests, Examples[)]"
"ERROR: Forgot to call TRIBITS_PACKAGE_POSTPROCESS[(][)] .*/TribitsExampleProject/PkgWithUserErrors/CMakeLists.txt"
ALWAYS_FAIL_ON_ZERO_RETURN
)

TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_PkgWithUserErrors_SKIP_PACKAGE_INIT
OVERALL_WORKING_DIRECTORY TEST_NAME
OVERALL_NUM_MPI_PROCS 1

TEST_0
MESSAGE "Copy TribitsExampleProject so that we can copy in PkgWithUserErrors."
CMND cp
ARGS -r ${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject .

TEST_1
MESSAGE "Copy PkgWithUserErrors to base dir."
CMND cp
ARGS -r ${CMAKE_CURRENT_SOURCE_DIR}/PkgWithUserErrors
TribitsExampleProject/.

TEST_2
MESSAGE "Configure PkgWithUserErrors"
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_SKIP_TRIBITS_PACKAGE_INIT=TRUE
-DPkgWithUserErrors_ADD_LIBRARY_BEFORE_POST_PROCESS=TRUE
TribitsExampleProject
PASS_REGULAR_EXPRESSION_ALL
"Must call TRIBITS_PACKAGE[(][)] before TRIBITS_ADD_LIBRARY[(][)]"
"Configuring incomplete, errors occurred!"
ALWAYS_FAIL_ON_ZERO_RETURN

TEST_3
MESSAGE "Configure PkgWithUserErrors"
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_SKIP_TRIBITS_PACKAGE_INIT=TRUE
-DPkgWithUserErrors_ADD_LIBRARY_BEFORE_POST_PROCESS=FALSE
-DPkgWithUserErrors_ADD_EXECUTABLE_BEFORE_POST_PROCESS=TRUE
TribitsExampleProject
PASS_REGULAR_EXPRESSION_ALL
"Must call TRIBITS_PACKAGE[(][)] before TRIBITS_ADD_EXECUTABLE[(][)]"
"Configuring incomplete, errors occurred!"
ALWAYS_FAIL_ON_ZERO_RETURN

TEST_4
MESSAGE "Configure PkgWithUserErrors"
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_SKIP_TRIBITS_PACKAGE_INIT=TRUE
-DPkgWithUserErrors_ADD_LIBRARY_BEFORE_POST_PROCESS=FALSE
-DPkgWithUserErrors_ADD_EXECUTABLE_BEFORE_POST_PROCESS=""
-DPkgWithUserErrors_SKIP_PACKAGE_TESTS=TRUE
TribitsExampleProject
PASS_REGULAR_EXPRESSION_ALL
"Must call TRIBITS_PACKAGE[(][)] before TRIBITS_PACKAGE_POSTPROCESS[(][)]"
"Configuring incomplete, errors occurred!"
ALWAYS_FAIL_ON_ZERO_RETURN

)

TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_PkgWithUserErrors_TARGETS_AFTER_POSTPROCESS
OVERALL_WORKING_DIRECTORY TEST_NAME
OVERALL_NUM_MPI_PROCS 1

TEST_0
MESSAGE "Copy TribitsExampleProject so that we can copy in PkgWithUserErrors."
CMND cp
ARGS -r ${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject .

TEST_1
MESSAGE "Copy PkgWithUserErrors to base dir."
CMND cp
ARGS -r ${CMAKE_CURRENT_SOURCE_DIR}/PkgWithUserErrors
TribitsExampleProject/.

TEST_2
MESSAGE "Configure PkgWithUserErrors"
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_ADD_LIBRARY_BEFORE_POST_PROCESS=FALSE
-DPkgWithUserErrors_ADD_LIBRARY_AFTER_POST_PROCESS=TRUE
TribitsExampleProject
PASS_REGULAR_EXPRESSION_ALL
"Must call TRIBITS_ADD_LIBRARY[(][)] before TRIBITS_PACKAGE_POSTPROCESS[(][)] in"
"Configuring incomplete, errors occurred!"
ALWAYS_FAIL_ON_ZERO_RETURN

TEST_3
MESSAGE "Configure PkgWithUserErrors"
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_ADD_LIBRARY_AFTER_POST_PROCESS=FALSE
-DPkgWithUserErrors_ADD_EXECUTABLE_AFTER_POST_PROCESS=TRUE
TribitsExampleProject
PASS_REGULAR_EXPRESSION_ALL
"Must call TRIBITS_ADD_EXECUTABLE[(][)] before TRIBITS_PACKAGE_POSTPROCESS[(][)] in"
"Configuring incomplete, errors occurred!"
ALWAYS_FAIL_ON_ZERO_RETURN

)
51 changes: 51 additions & 0 deletions test/core/ExamplesUnitTests/PkgWithUserErrors/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# TRIBITS_PACKAGE() will be called by default
IF(NOT ${PACKAGE_NAME}_SKIP_TRIBITS_PACKAGE_INIT)
TRIBITS_PACKAGE(PkgWithUserErrors)
ENDIF()

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})

# Not added by defult
IF(${PACKAGE_NAME}_ADD_LIBRARY_BEFORE_POST_PROCESS)
MESSAGE("building library")
TRIBITS_ADD_LIBRARY(
pkgwithusererrors
HEADERS PkgWithUserErrorsLib.hpp
SOURCES PkgWithUserErrorsLib.cpp
)
ENDIF()

# Not added by defult
IF(${PACKAGE_NAME}_ADD_EXECUTABLE_BEFORE_POST_PROCESS)
MESSAGE("building exectuable")
TRIBITS_ADD_EXECUTABLE(
usererrorexec
SOURCES PkgWithUserErrorsEX.cpp
)
ENDIF()

IF(NOT ${PACKAGE_NAME}_SKIP_PACKAGE_TESTS)
TRIBITS_ADD_TEST_DIRECTORIES(test)
ENDIF()

# TRIBITS_PACKAGE_POSTPROCESS() will be called by default
IF (NOT ${PACKAGE_NAME}_SKIP_PACKAGE_POST_PROCESS)
TRIBITS_PACKAGE_POSTPROCESS()
ENDIF()

# Not added by defult
IF (${PACKAGE_NAME}_ADD_LIBRARY_AFTER_POST_PROCESS)
TRIBITS_ADD_LIBRARY(
pkgwithusererrors2
HEADERS PkgWithUserErrorsLib.hpp
SOURCES PkgWithUserErrorsLib.cpp
)
ENDIF()

# Not added by defult
IF(${PACKAGE_NAME}_ADD_EXECUTABLE_AFTER_POST_PROCESS)
TRIBITS_ADD_EXECUTABLE(
usererrorexec
SOURCES PkgWithUserErrorsEX.cpp
)
ENDIF()
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
TRIBITS_REPOSITORY_DEFINE_PACKAGES(
PkgWithUserErrors . PT
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <iostream>

int main() {
std::cout << "Package With User Errors\n";
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "PkgWithUserErrorsLib.hpp"

std::string PkgWithUserErrors::theThing()
{
return "PkgWithUserErrorsThing";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef PKGWITHUSSERERRORSLIB_HPP_
#define PKGWITHUSSERERRORSLIB_HPP_

#include <string>

namespace PkgWithUserErrors {

std::string theThing();

}

#endif /* PKGWITHUSSERERRORSLIB_HPP_ */
9 changes: 9 additions & 0 deletions test/core/ExamplesUnitTests/PkgWithUserErrors/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
================
TargetDefinesPkg
================

The purpose of this package is to demonstrate and test the usage of the
TRIBITS_ADD_EXECUTABLE() TARGET_DEFINES argument and to show the bad behavior
of the old DEFINES argument.

See GitHub TriBITS Issue #90 for more details.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TRIBITS_REPOSITORY_DEFINE_TPLS()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TRIBITS_PACKAGE_DEFINE_DEPENDENCIES()
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TRIBITS_ADD_EXECUTABLE_AND_TEST( PkgWithUserErrorsTest
SOURCES PkgWithUserErrorsTest.cpp
NUM_MPI_PROCS 1
PASS_REGULAR_EXPRESSION
"PkgWithUserErrorsLib returns PkgWithUserErrorsThing"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <iostream>

#include "PkgWithUserErrorsLib.hpp"

int main() {
std::cout << "PkgWithUserErrorsLib returns "
<< PkgWithUserErrors::theThing() << "\n";
return 0;
}
12 changes: 12 additions & 0 deletions tribits/core/package_arch/TribitsAddExecutable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,18 @@ FUNCTION(TRIBITS_ADD_EXECUTABLE EXE_NAME)
MESSAGE("")
MESSAGE("TRIBITS_ADD_EXECUTABLE: ${EXE_NAME} ${ARGN}")
ENDIF()

#
# Confirm that TRIBITS_PACKAGE() was called prior to adding executable
#

IF(NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_CALLED)
MESSAGE(FATAL_ERROR "Must call TRIBITS_PACKAGE() before TRIBITS_ADD_EXECUTABLE() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}")
ENDIF()

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

#
# A) Parse the input arguments
Expand Down
11 changes: 9 additions & 2 deletions tribits/core/package_arch/TribitsGlobalMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2287,12 +2287,19 @@ MACRO(TRIBITS_CONFIGURE_ENABLED_PACKAGES)
PRINT_VAR(${TRIBITS_PACKAGE}_BINARY_DIR)
ENDIF()

TRIBITS_TRACE_FILE_PROCESSING(PACKAGE ADD_SUBDIR
SET(TRIBITS_PACKAGE_CMAKELIST_FILE
"${${TRIBITS_PACKAGE}_SOURCE_DIR}/CMakeLists.txt")
TRIBITS_TRACE_FILE_PROCESSING(PACKAGE ADD_SUBDIR
"${TRIBITS_PACKAGE_CMAKELIST_FILE}")
IF (NOT ${TRIBITS_PACKAGE}_SOURCE_DIR STREQUAL ${PROJECT_NAME}_SOURCE_DIR)
ADD_SUBDIRECTORY(${${TRIBITS_PACKAGE}_SOURCE_DIR} ${${TRIBITS_PACKAGE}_BINARY_DIR})
ELSE()
INCLUDE("${${TRIBITS_PACKAGE}_SOURCE_DIR}/CMakeLists.txt")
INCLUDE("${TRIBITS_PACKAGE_CMAKELIST_FILE}")
ENDIF()
IF (NOT ${PACKAGE_NAME}_TRIBITS_PACAKGE_POSTPROCESS)
MESSAGE(FATAL_ERROR
"ERROR: Forgot to call TRIBITS_PACKAGE_POSTPROCESS() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}"
)
ENDIF()

LIST(APPEND ENABLED_PACKAGE_LIBS_TARGETS ${TRIBITS_PACKAGE}_libs)
Expand Down
10 changes: 9 additions & 1 deletion tribits/core/package_arch/TribitsLibraryMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,16 @@ ENDFUNCTION()
#
FUNCTION(TRIBITS_ADD_LIBRARY LIBRARY_NAME_IN)

SET(LIBRARY_NAME_PREFIX "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}")
IF(NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_CALLED)
MESSAGE(FATAL_ERROR "Must call TRIBITS_PACKAGE() before TRIBITS_ADD_LIBRARY() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}")
ENDIF()

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


SET(LIBRARY_NAME_PREFIX "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}")
SET(LIBRARY_NAME ${LIBRARY_NAME_PREFIX}${LIBRARY_NAME_IN})

IF (${PROJECT_NAME}_VERBOSE_CONFIGURE)
Expand Down
Loading

0 comments on commit 43d2603

Please sign in to comment.