Skip to content

Commit

Permalink
Foundation for testing for user errors (#200)
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
bartlettroscoe committed Aug 11, 2017
1 parent d03fdde commit cfb441b
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 0 deletions.
56 changes: 56 additions & 0 deletions test/core/ExamplesUnitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

)



13 changes: 13 additions & 0 deletions test/core/ExamplesUnitTests/PkgWithUserErrors/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
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 "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;
}

0 comments on commit cfb441b

Please sign in to comment.