libMesh
Functions | Variables
driver.C File Reference

Go to the source code of this file.

Functions

void add_matching_tests_to_runner (CppUnit::Test *test, const std::regex &r, CppUnit::TextUi::TestRunner &runner, CppUnit::TestSuite &rejects)
 
int main (int argc, char **argv)
 

Variables

libMesh::Parallel::Communicator * TestCommWorld
 

Function Documentation

◆ add_matching_tests_to_runner()

void add_matching_tests_to_runner ( CppUnit::Test *  test,
const std::regex &  r,
CppUnit::TextUi::TestRunner &  runner,
CppUnit::TestSuite &  rejects 
)

Definition at line 17 of file driver.C.

21 {
22  // If we running all tests we just add the "All Tests" test and then return
23  if (test->getName() == "All Tests" && std::regex_search(test->getName(), r))
24  {
25  libMesh::out << test->getName() << std::endl;
26  runner.addTest(test);
27  return;
28  }
29 
30  if (test->getChildTestCount() == 0)
31  {
32  // Add the test to the runner
33  if (std::regex_search(test->getName(), r))
34  {
35  libMesh::out << test->getName() << std::endl;
36  runner.addTest(test);
37  }
38  // Add the test to the rejects it can be cleaned up later
39  else
40  rejects.addTest(test);
41  }
42 
43  // Call this recursively on each of our children, if any.
44  for (int i = 0; i < test->getChildTestCount(); i++)
45  add_matching_tests_to_runner(test->getChildTestAt(i), r, runner, rejects);
46 }

References libMesh::out.

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 51 of file driver.C.

52 {
53  // Initialize the library. This is necessary because the library
54  // may depend on a number of other libraries (i.e. MPI and Petsc)
55  // that require initialization before use.
56  libMesh::LibMeshInit init(argc, argv);
57  TestCommWorld = &init.comm();
58 
59  // We can now run all tests that match a regular expression, for
60  // example, "--re PartitionerTest" will match all the Partitioner
61  // unit tests. If the user does not specify a regex, we run all the
62  // tests returned by makeTest().
63 
64  // An example regex_string that would _exactly_ match a _single_ test is:
65  // "PartitionerTest_HilbertSFCPartitioner_ReplicatedMesh::testPartition2"
66  // On the other hand, the regex "HilbertSFC" would match all of the
67  // following tests:
68  //
69  // PartitionerTest_HilbertSFCPartitioner_ReplicatedMesh
70  // PartitionerTest_HilbertSFCPartitioner_ReplicatedMesh::testPartitionEmpty
71  // PartitionerTest_HilbertSFCPartitioner_ReplicatedMesh::testPartition1
72  // PartitionerTest_HilbertSFCPartitioner_ReplicatedMesh::testPartition2
73  // PartitionerTest_HilbertSFCPartitioner_ReplicatedMesh::testPartitionNProc
74  //
75  // If the user does not provide a a regex, the default re is "All Tests",
76  // which runs all the unit tests.
77 
78  // Read command line argument specifying the regular expression.
79  std::string regex_string = "All Tests";
80  regex_string = libMesh::command_line_next("--re", regex_string);
81 
82  // Recursively add tests matching the regex tothe runner object.
83  CppUnit::TextUi::TestRunner runner;
84 
85  // The Cppunit registry object that knows about all the tests.
86  CppUnit::TestFactoryRegistry & registry = CppUnit::TestFactoryRegistry::getRegistry();
87 
88  // A test suite container for holding tests not matching the regex. When main's
89  // scope ends, this class's destructor will delete the rejected tests
90  CppUnit::TestSuite rejects("rejects");
91 
92 #ifdef LIBMESH_HAVE_CXX11_REGEX
93  // Make regex object from user's input.
94  std::regex the_regex(regex_string);
95 
96  // Add all tests which match the re to the runner object.
97  libMesh::out << "Will run the following tests:" << std::endl;
98  add_matching_tests_to_runner(registry.makeTest(), the_regex, runner, rejects);
99 #else
100  // If no C++11 <regex> just run all the tests.
101  runner.addTest(registry.makeTest());
102 #endif
103 
104  // Finally, run the matching tests.
105  if (runner.run())
106  return 0;
107 
108  return 1;
109 }

References add_matching_tests_to_runner(), libMesh::command_line_next(), libMesh::TriangleWrapper::init(), libMesh::out, and TestCommWorld.

Variable Documentation

◆ TestCommWorld

libMesh::Parallel::Communicator* TestCommWorld

Definition at line 111 of file driver.C.

Referenced by AllSecondOrderTest::allSecondOrder(), GetBoundaryPointsTest::build_mesh(), BoundaryMeshTest::build_mesh(), MixedDimensionMeshTest::build_mesh(), MeshfunctionDFEM::build_mesh(), SlitMeshTest::build_mesh(), MixedDimensionNonUniformRefinement::build_mesh(), MixedDimensionNonUniformRefinementTriangle::build_mesh(), MixedDimensionNonUniformRefinement3D::build_mesh(), OverlappingTestBase::build_quad_mesh(), ExtraIntegersTest::checkpoint_helper(), NodalNeighborsTest::do_test(), ParallelSyncTest::fill_scalar_data(), ParallelSyncTest::fill_vector_data(), main(), TimeSolverTestImplementation< NewmarkSolver >::run_test_with_exact_soln(), BoundaryMeshTest::sanityCheck(), ElemTest< elem_type >::setUp(), ParsedFEMFunctionTest::setUp(), PetscMatrixTest::setUp(), NumericVectorTest< DistributedVector< Number > >::setUp(), RationalMapTest< elem_type >::setUp(), DiagonalMatrixTest::setUp(), FETest< order, family, elem_type >::setUp(), MeshSpatialDimensionTest::test1D(), MeshSpatialDimensionTest::test2D(), ExtraIntegersTest::test_helper(), DistortTest::test_helper_2D(), AllTriTest::test_helper_2D(), DistortTest::test_helper_3D(), AllTriTest::test_helper_3D(), MeshFunctionTest::test_p_level(), EquationSystemsTest::testAddSystem(), ParallelTest::testAllGather(), ParallelTest::testAllGatherEmptyVectorString(), ParallelTest::testAllGatherHalfEmptyVectorString(), ParallelPointTest::testAllGatherPairPointPoint(), ParallelPointTest::testAllGatherPairRealPoint(), ParallelPointTest::testAllGatherPoint(), ParallelTest::testAllGatherString(), ParallelTest::testAllGatherVectorString(), SystemsTest::testAssemblyWithDgFemContext(), ParallelTest::testBarrier(), SystemsTest::testBlockRestrictedVarNDofs(), SystemsTest::testBoundaryProjectCube(), ParallelTest::testBroadcast(), ParallelTest::testBroadcastNestedType(), ParallelPointTest::testBroadcastPoint(), ParallelPointTest::testBroadcastVectorValue(), DofMapTest::testConstraintLoopDetection(), EquationSystemsTest::testConstruction(), PackedRangeTest::testContainerSendReceive(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), EquationSystemsTest::testDisableDefaultGhosting(), SystemsTest::testDofCouplingWithVarGroups(), DofMapTest::testDofOwner(), MeshInputTest::testDynaReadElem(), MeshInputTest::testDynaReadPatch(), BoundaryInfoTest::testEdgeBoundaryConditions(), MeshInputTest::testExodusCopyElementSolution(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), MeshExtruderTest::testExtruder(), ParallelTest::testGather(), ParallelTest::testGatherString(), MessageTagTest::testGetUniqueTagAuto(), MessageTagTest::testGetUniqueTagManual(), ParsedFEMFunctionTest::testGradients(), ParsedFEMFunctionTest::testHessians(), ParallelTest::testInfinityMax(), ParallelTest::testInfinityMin(), EquationSystemsTest::testInit(), ParsedFEMFunctionTest::testInlineGetter(), ParsedFEMFunctionTest::testInlineSetter(), ParallelPointTest::testIrecvSend(), ParallelTest::testIrecvSend(), ParallelPointTest::testIsendRecv(), ParallelTest::testIsendRecv(), PointLocatorTest::testLocator(), MappedSubdomainPartitionerTest::testMappedSubdomainPartitioner(), ParallelTest::testMax(), ParallelTest::testMaxloc(), ParallelTest::testMaxlocReal(), BoundaryInfoTest::testMesh(), MeshInputTest::testMeshMoveConstructor(), MeshStitchTest::testMeshStitch(), ParallelTest::testMin(), ParallelTest::testMinloc(), ParallelTest::testMinlocReal(), ParsedFEMFunctionTest::testNormals(), PackedRangeTest::testNullAllGather(), PackedRangeTest::testNullSendReceive(), PartitionerTest< PartitionerSubclass, MeshClass >::testPartition(), PartitionerTest< PartitionerSubclass, MeshClass >::testPartitionEmpty(), PartitionerTest< PartitionerSubclass, MeshClass >::testPartitionNProc(), EquationSystemsTest::testPostInitAddElem(), EquationSystemsTest::testPostInitAddRealSystem(), EquationSystemsTest::testPostInitAddSystem(), SystemsTest::testProjectCube(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectLine(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), SystemsTest::testProjectSquare(), ParallelSyncTest::testPull(), ParallelSyncTest::testPullImpl(), ParallelSyncTest::testPullOversized(), ParallelSyncTest::testPullVecVec(), ParallelSyncTest::testPullVecVecImpl(), ParallelSyncTest::testPullVecVecOversized(), ParallelSyncTest::testPush(), ParallelSyncTest::testPushImpl(), ParallelSyncTest::testPushMultimap(), ParallelSyncTest::testPushMultimapImpl(), ParallelSyncTest::testPushMultimapOversized(), ParallelSyncTest::testPushMultimapVecVec(), ParallelSyncTest::testPushMultimapVecVecImpl(), ParallelSyncTest::testPushMultimapVecVecOversized(), ParallelSyncTest::testPushOversized(), ParallelSyncTest::testPushVecVec(), ParallelSyncTest::testPushVecVecImpl(), ParallelSyncTest::testPushVecVecOversized(), ParallelTest::testRecvIsendSets(), ParallelTest::testRecvIsendVecVecs(), EquationSystemsTest::testRefineThenReinitPreserveFlags(), EquationSystemsTest::testReinitWithNodeElem(), EquationSystemsTest::testRepartitionThenReinit(), SlitMeshRefinedSystemTest::testRestart(), ParallelTest::testScatter(), ParallelTest::testSemiVerify(), ParallelTest::testSendRecvVecVecs(), BoundaryInfoTest::testShellFaceConstraints(), InfFERadialTest::testSingleOrder(), ParallelSortTest::testSort(), ParallelTest::testSplit(), ParallelTest::testSplitByType(), CheckpointIOTest::testSplitter(), ParsedFEMFunctionTest::testValues(), WriteEdgesetData::testWrite(), WriteSidesetData::testWrite(), WriteVecAndScalar::testWrite(), and SystemsTest::tripleValueTest().

libMesh::command_line_next
T command_line_next(std::string name, T default_value)
Use GetPot's search()/next() functions to get following arguments from the command line.
Definition: libmesh.C:963
add_matching_tests_to_runner
void add_matching_tests_to_runner(CppUnit::Test *test, const std::regex &r, CppUnit::TextUi::TestRunner &runner, CppUnit::TestSuite &rejects)
Definition: driver.C:17
libMesh::TriangleWrapper::init
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
TestCommWorld
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:111
libMesh::LibMeshInit
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
Definition: libmesh.h:83
libMesh::out
OStreamProxy out