From cfb441b2c13acc0276eb6adac0c362b6669db0dc Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 20 Jul 2017 14:46:45 -0600 Subject: [PATCH] Foundation for testing for user errors (#200) This adds a new dummy testing TriBITS package PkgWithUserErrors that will be used to test for user errors. In following commits, we will optionally break this various ways! --- test/core/ExamplesUnitTests/CMakeLists.txt | 56 +++++++++++++++++++ .../PkgWithUserErrors/CMakeLists.txt | 13 +++++ .../PkgWithUserErrors/PackagesList.cmake | 3 + .../PkgWithUserErrorsLib.cpp | 6 ++ .../PkgWithUserErrorsLib.hpp | 12 ++++ .../PkgWithUserErrors/README | 9 +++ .../PkgWithUserErrors/TPLsList.cmake | 1 + .../cmake/Dependencies.cmake | 1 + .../PkgWithUserErrors/test/CMakeLists.txt | 6 ++ .../test/PkgWithUserErrorsTest.cpp | 9 +++ 10 files changed, 116 insertions(+) create mode 100644 test/core/ExamplesUnitTests/PkgWithUserErrors/CMakeLists.txt create mode 100644 test/core/ExamplesUnitTests/PkgWithUserErrors/PackagesList.cmake create mode 100644 test/core/ExamplesUnitTests/PkgWithUserErrors/PkgWithUserErrorsLib.cpp create mode 100644 test/core/ExamplesUnitTests/PkgWithUserErrors/PkgWithUserErrorsLib.hpp create mode 100644 test/core/ExamplesUnitTests/PkgWithUserErrors/README create mode 100644 test/core/ExamplesUnitTests/PkgWithUserErrors/TPLsList.cmake create mode 100644 test/core/ExamplesUnitTests/PkgWithUserErrors/cmake/Dependencies.cmake create mode 100644 test/core/ExamplesUnitTests/PkgWithUserErrors/test/CMakeLists.txt create mode 100644 test/core/ExamplesUnitTests/PkgWithUserErrors/test/PkgWithUserErrorsTest.cpp diff --git a/test/core/ExamplesUnitTests/CMakeLists.txt b/test/core/ExamplesUnitTests/CMakeLists.txt index 1cf7549d0..4e516df94 100644 --- a/test/core/ExamplesUnitTests/CMakeLists.txt +++ b/test/core/ExamplesUnitTests/CMakeLists.txt @@ -2989,3 +2989,59 @@ 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 + 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_MPI_1 [.]+ +Passed" + ALWAYS_FAIL_ON_NONZERO_RETURN + + ) + + + diff --git a/test/core/ExamplesUnitTests/PkgWithUserErrors/CMakeLists.txt b/test/core/ExamplesUnitTests/PkgWithUserErrors/CMakeLists.txt new file mode 100644 index 000000000..c38e126f8 --- /dev/null +++ b/test/core/ExamplesUnitTests/PkgWithUserErrors/CMakeLists.txt @@ -0,0 +1,13 @@ +TRIBITS_PACKAGE(PkgWithUserErrors) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) + +TRIBITS_ADD_LIBRARY( + pkgwithusererrors + HEADERS PkgWithUserErrorsLib.hpp + SOURCES PkgWithUserErrorsLib.cpp + ) + +TRIBITS_ADD_TEST_DIRECTORIES(test) + +TRIBITS_PACKAGE_POSTPROCESS() diff --git a/test/core/ExamplesUnitTests/PkgWithUserErrors/PackagesList.cmake b/test/core/ExamplesUnitTests/PkgWithUserErrors/PackagesList.cmake new file mode 100644 index 000000000..83351f948 --- /dev/null +++ b/test/core/ExamplesUnitTests/PkgWithUserErrors/PackagesList.cmake @@ -0,0 +1,3 @@ +TRIBITS_REPOSITORY_DEFINE_PACKAGES( + PkgWithUserErrors . PT + ) diff --git a/test/core/ExamplesUnitTests/PkgWithUserErrors/PkgWithUserErrorsLib.cpp b/test/core/ExamplesUnitTests/PkgWithUserErrors/PkgWithUserErrorsLib.cpp new file mode 100644 index 000000000..687bee9a9 --- /dev/null +++ b/test/core/ExamplesUnitTests/PkgWithUserErrors/PkgWithUserErrorsLib.cpp @@ -0,0 +1,6 @@ +#include "PkgWithUserErrorsLib.hpp" + +std::string PkgWithUserErrors::theThing() +{ + return "PkgWithUserErrorsThing"; +} diff --git a/test/core/ExamplesUnitTests/PkgWithUserErrors/PkgWithUserErrorsLib.hpp b/test/core/ExamplesUnitTests/PkgWithUserErrors/PkgWithUserErrorsLib.hpp new file mode 100644 index 000000000..ec8ffd683 --- /dev/null +++ b/test/core/ExamplesUnitTests/PkgWithUserErrors/PkgWithUserErrorsLib.hpp @@ -0,0 +1,12 @@ +#ifndef PKGWITHUSSERERRORSLIB_HPP_ +#define PKGWITHUSSERERRORSLIB_HPP_ + +#include + +namespace PkgWithUserErrors { + +std::string theThing(); + +} + +#endif /* PKGWITHUSSERERRORSLIB_HPP_ */ diff --git a/test/core/ExamplesUnitTests/PkgWithUserErrors/README b/test/core/ExamplesUnitTests/PkgWithUserErrors/README new file mode 100644 index 000000000..5749d74f3 --- /dev/null +++ b/test/core/ExamplesUnitTests/PkgWithUserErrors/README @@ -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. diff --git a/test/core/ExamplesUnitTests/PkgWithUserErrors/TPLsList.cmake b/test/core/ExamplesUnitTests/PkgWithUserErrors/TPLsList.cmake new file mode 100644 index 000000000..402fb985c --- /dev/null +++ b/test/core/ExamplesUnitTests/PkgWithUserErrors/TPLsList.cmake @@ -0,0 +1 @@ +TRIBITS_REPOSITORY_DEFINE_TPLS() diff --git a/test/core/ExamplesUnitTests/PkgWithUserErrors/cmake/Dependencies.cmake b/test/core/ExamplesUnitTests/PkgWithUserErrors/cmake/Dependencies.cmake new file mode 100644 index 000000000..a0867faea --- /dev/null +++ b/test/core/ExamplesUnitTests/PkgWithUserErrors/cmake/Dependencies.cmake @@ -0,0 +1 @@ +TRIBITS_PACKAGE_DEFINE_DEPENDENCIES() diff --git a/test/core/ExamplesUnitTests/PkgWithUserErrors/test/CMakeLists.txt b/test/core/ExamplesUnitTests/PkgWithUserErrors/test/CMakeLists.txt new file mode 100644 index 000000000..af220dcc9 --- /dev/null +++ b/test/core/ExamplesUnitTests/PkgWithUserErrors/test/CMakeLists.txt @@ -0,0 +1,6 @@ +TRIBITS_ADD_EXECUTABLE_AND_TEST( PkgWithUserErrorsTest + SOURCES PkgWithUserErrorsTest.cpp + NUM_MPI_PROCS 1 + PASS_REGULAR_EXPRESSION + "PkgWithUserErrorsLib returns PkgWithUserErrorsThing" + ) diff --git a/test/core/ExamplesUnitTests/PkgWithUserErrors/test/PkgWithUserErrorsTest.cpp b/test/core/ExamplesUnitTests/PkgWithUserErrors/test/PkgWithUserErrorsTest.cpp new file mode 100644 index 000000000..00495eb00 --- /dev/null +++ b/test/core/ExamplesUnitTests/PkgWithUserErrors/test/PkgWithUserErrorsTest.cpp @@ -0,0 +1,9 @@ +#include + +#include "PkgWithUserErrorsLib.hpp" + +int main() { + std::cout << "PkgWithUserErrorsLib returns " + << PkgWithUserErrors::theThing() << "\n"; + return 0; +}