90 if (
a.groupName <
b.groupName) {
93 else if (
a.groupName >
b.groupName) {
96 return a.insertionIndex <
b.insertionIndex;
102 const std::string testName)
104 std::ostringstream
oss;
105 oss << groupName<<
"_"<<testName<<
"_UnitTest";
120 const std::string::size_type
npos = std::string::npos;
216 const bool globallyReduceUnitTestResult)
218 getData().globallyReduceUnitTestResult = globallyReduceUnitTestResult;
224 return getData().globallyReduceUnitTestResult;
233 using std::setprecision;
240 out <<
"\n***\n*** Unit test suite ...\n***\n\n";
258 out <<
"\nSorting tests by group name then by the order they were added ...";
264 out <<
"\nRunning unit tests ...\n\n";
308 oss =
rcp(
new std::ostringstream);
336 <<
"Location: "<<
utd.unitTest->unitTestFile()<<
":"
337 <<
utd.unitTest->unitTestFileLineNumber()<<
"\n";
355 <<
"Location: "<<
utd.unitTest->unitTestFile()<<
":"
356 <<
utd.unitTest->unitTestFileLineNumber()<<
"\n";
364 out <<
"[Not Run]\n";
380 out <<
"\nThe following tests FAILED:\n";
390 <<
"\nSummary: total = " << testCounter
401 <<
", failed = ???\n";
419 *out <<
"\nEnd Result: TEST FAILED" << std::endl;
426 *out <<
"\nEnd Result: TEST PASSED" << std::endl;
428 *out <<
"\nEnd Result: TEST FAILED" << std::endl;
438 const std::string groupName,
const std::string
testName_in )
462 clp->addOutputSetupOptions(
true);
476 "show-test-details", &
getData().showTestDetails,
478 "Level of detail to show in the tests"
481 "details", &
getData().showTestDetails,
483 "Short for --show-test-details"
487 "show-src-location",
"no-show-src-location", &
getData().showSrcLocation,
488 "If true, then the location of the unit test source code is shown."
489 " Only meaningful if --show-test-details=ALL."
493 "show-fail-src-location",
"no-show-fail-src-location", &
getData().showFailSrcLocation,
494 "If true, then the location of every failed unit test check is printed."
498 "globally-reduce-test-result",
"no-globally-reduce-test-result",
499 &
getData().globallyReduceUnitTestResult,
500 "If true, individual unit test pass/fail is globally reduced across MPI processes."
504 "group-name", &
getData().groupName,
505 "If specified, selects only tests that match the group name glob." );
508 "Short for --group-name." );
511 "test-name", &
getData().testName,
512 "If specified, selects only tests that match the test name glob." );
515 "Short for --test-name." );
518 "not-unit-test", &
getData().notUnitTestName,
519 "If specified, full unit tests with glob matches will *not* be run." );
522 "no-op",
"do-op", &
getData().noOp,
523 "If --no-op, then only the names of the tests that would be run are run."
540 if (
getData().globallyReduceUnitTestResult) {
551 out <<
"NOTE: Global reduction shows failures on other processes!\n"
552 <<
"(rerun with --output-to-root-rank-only=-1 to see output\n"
553 <<
"from other processes to see what process failed!)\n";
572 out <<
"NOTE: Unit test failed on all processes!\n";
577 out <<
"NOTE: Unit test failed on processes = " <<
procsThatFailed <<
"\n"
578 <<
"(rerun with --output-to-root-rank-only=<procID> to see output\n"
579 <<
"from individual processes where the unit test is failing!)\n";
Templated array class derived from the STL std::vector.
Basic command line parser for input from (argc,argv[])
Teuchos header file which uses auto-configuration information to include necessary C++ headers.
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)
Simple macro that catches and reports standard exceptions and other exceptions.
Utilities to make writing tests easier.
Basic wall-clock timer class.
void push_back(const value_type &x)
int size(const Comm< Ordinal > &comm)
Get the number of processes in the communicator.
Class that helps parse command line input arguments from (argc,argv[]) and set options.
EParseCommandLineReturn
Return value for CommandLineProcessor::parse(). Note: These enums are all given non-negative values s...
EParseCommandLineReturn parse(int argc, char *argv[], std::ostream *errout=&std::cerr) const
Parse a command line.
void printFinalTimerSummary(const Ptr< std::ostream > &out=null)
Call to print timers so that they don't get printed in the destructor.
static int sum(int localVal)
Sum a set of integers across processes.
static int getNProc()
The number of processes in MPI_COMM_WORLD.
static void allGather(int localVal, const ArrayView< int > &allVals)
Global all-to-all of a set of integers across processes.
Concrete serial communicator subclass.
bool runUnitTest(FancyOStream &out) const
std::string notUnitTestName
Teuchos::Array< UnitTestData > unitTests_t
bool globallyReduceUnitTestResult
EShowTestDetails showTestDetails
static void setUpCLP(const Ptr< CommandLineProcessor > &clp)
static bool verboseUnitTests()
Returns if unit tests are verbose or not.
static bool runUnitTests(FancyOStream &out)
Run the registered unit tests.
static InstanceData & getData()
static bool getGloballyReduceTestResult()
Get if the unit tests should reduce across processes or not.
static CommandLineProcessor & getCLP()
Return the CLP to add options to.
static int runUnitTestsFromMain(int argc, char *argv[])
Run the unit tests from main() passing in (argc, argv).
static void addUnitTest(UnitTestBase *unitTest, const std::string groupName, const std::string testName)
Add an unit test (called indirectly through macros.
static bool runUnitTestImpl(const UnitTestBase &unitTest, FancyOStream &out)
static void setGloballyReduceTestResult(const bool globallyReduceUnitTestResult)
Set if the unit tests should reduce pass/fail across processes.
static RCP< FancyOStream > getDefaultOStream()
Get the default output stream object.
std::ostream subclass that performs the magic of indenting data sent to an std::ostream object among ...
#define TEUCHOS_ASSERT(assertion_test)
This macro is throws when an assert fails.
#define TEUCHOS_ASSERT_EQUALITY(val1, val2)
This macro is checks that to numbers are equal and if not then throws an exception with a good error ...
bool is_null(const std::shared_ptr< T > &p)
Returns true if p.get()==NULL.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
bool operator<(BigUInt< n > const &a, BigUInt< n > const &b)
bool strMatch(const std::string &fullMatchStr, const std::string &str)
@ SHOW_TEST_DETAILS_TEST_NAMES
@ SHOW_TEST_DETAILS_FINAL_RESULTS
std::string getUnitTestName(const std::string groupName, const std::string testName)
bool showTestFailureLocation()
Return if TEUCHOS_PASS_FAIL(...) should print test failure location.
const Teuchos::UnitTestBase * unitTest
static int insersionIndexCounter_
UnitTestData(Teuchos::UnitTestBase *unitTest_in, const std::string groupName_in, const std::string testName_in)