DuneTestMacros¶
Tools for integrating tests into the DUNE build system.
- dune_declare_test_label¶
Declare labels for
dune_add_test().dune_declare_test_label(LABELS <labels...>)
LABELSNames of labels to declare. Label names must be non-empty and may contain only alphanumeric characters plus
-and_so they remain easy to use inctest -Lregular expressions.
Labels are normally declared on demand by
dune_add_test(). Call this command explicitly if you wantbuild_<label>_teststargets to exist even when no test with that label is added in the current configuration. The labelquickis always predeclared.
- dune_add_test¶
Add a test to the DUNE testing suite.
dune_add_test( [NAME <name>] [SOURCES <sources...>] [TARGET <target>] [COMPILE_DEFINITIONS <def>...] [COMPILE_FLAGS <flag>...] [LINK_LIBRARIES <lib>...] [EXPECT_COMPILE_FAIL] [EXPECT_FAIL] [CMD_ARGS <arg>...] [MPI_RANKS <ranks>...] [CMAKE_GUARD <condition>...] [COMMAND <cmd>...] [COMPILE_ONLY] [TIMEOUT <seconds>] [WORKING_DIRECTORY <dir>] [LABELS <labels...>] )
NAMEName of the test. If omitted, the name is deduced from the single source file or the given target.
SOURCESSource files used to build the test executable. You must provide either
SOURCESorTARGET.TARGETExisting executable target to use for the test. You must provide either
SOURCESorTARGET.COMPILE_DEFINITIONSExtra compile definitions to add when
dune_add_test()creates the executable itself.COMPILE_FLAGSExtra non-definition compile flags to add when
dune_add_test()creates the executable itself.LINK_LIBRARIESExtra libraries to link when
dune_add_test()creates the executable itself.EXPECT_COMPILE_FAILExpect the test target to fail during compilation.
EXPECT_FAILExpect the test to compile but fail at run time.
CMD_ARGSAdditional command line arguments passed to the test command.
MPI_RANKSNumbers of MPI ranks with which the test should run. One ctest test is created for each rank count. Values larger than
DUNE_MAX_TEST_CORESare ignored. When this option is used,TIMEOUTmust also be specified.CMAKE_GUARDConditions evaluated by CMake before adding the test. Use this instead of guarding the call with a plain
if()when you want the test summary to report the case as skipped.COMMANDExact command line to execute for the test. If
CMD_ARGSis also given, those arguments are appended to the command.COMPILE_ONLYCompile the test during
make build_testsbut do not run it duringmake test.TIMEOUTTimeout in seconds. This overrides the default ctest timeout for the test.
WORKING_DIRECTORYWorking directory used when executing the test. By default this is the build directory corresponding to the current source directory.
LABELSLabels attached to the test. They also control creation of
build_<label>_teststargets. Usedune_declare_test_label()when you want such targets to exist unconditionally.
You may either create the executable yourself with
add_executable()and pass it throughTARGET, or letdune_add_test()create the executable fromSOURCES.
- DUNE_MAX_TEST_CORES¶
Upper bound for the number of processors a single test may use. The default is 2 when MPI is found and 1 otherwise.
- DUNE_BUILD_TESTS_ON_MAKE_ALL¶
If enabled, build all tests during
make all. Otherwise tests are built through thebuild_teststarget. This option does not apply to immutable targets such as imported or aliased targets.
- PYTHON_TEST¶
Marker used by
dune_python_add_test()to identify python tests. It disables the check for the existence of the target file.