ecbuild_add_test¶
Add a test as a script or an executable with a given list of source files.
ecbuild_add_test( [ TARGET <name> ]
[ SOURCES <source1> [<source2> ...] ]
[ OBJECTS <obj1> [<obj2> ...] ]
[ COMMAND <executable> ]
[ TYPE EXE|SCRIPT|PYTHON ]
[ LABELS <label1> [<label2> ...] ]
[ ARGS <argument1> [<argument2> ...] ]
[ RESOURCES <file1> [<file2> ...] ]
[ TEST_DATA <file1> [<file2> ...] ]
[ MPI <number-of-mpi-tasks> ]
[ OMP <number-of-threads-per-mpi-task> ]
[ ENABLED ON|OFF ]
[ LIBS <library1> [<library2> ...] ]
[ INCLUDES <path1> [<path2> ...] ]
[ DEFINITIONS <definition1> [<definition2> ...] ]
[ PERSISTENT <file1> [<file2> ...] ]
[ GENERATED <file1> [<file2> ...] ]
[ DEPENDS <target1> [<target2> ...] ]
[ TEST_DEPENDS <target1> [<target2> ...] ]
[ CONDITION <condition> ]
[ PROPERTIES <prop1> <val1> [<prop2> <val2> ...] ]
[ ENVIRONMENT <variable1> [<variable2> ...] ]
[ WORKING_DIRECTORY <path> ]
[ CFLAGS <flag1> [<flag2> ...] ]
[ CXXFLAGS <flag1> [<flag2> ...] ]
[ FFLAGS <flag1> [<flag2> ...] ]
[ LINKER_LANGUAGE <lang> ] )
Options¶
- TARGET : either TARGET or COMMAND must be provided, unless TYPE is PYTHON
- target name to be built
- SOURCES : required if TARGET is provided
- list of source files to be compiled
- OBJECTS : optional
- list of object libraries to add to this target
- COMMAND : either TARGET or COMMAND must be provided, unless TYPE is PYTHON
- command or script to execute (no executable is built)
- TYPE : optional
test type, one of:
EXE: run built executable, default if TARGET is provided SCRIPT: run command or script, default if COMMAND is provided PYTHON: run a Python script (requires the Python interpreter to be found) - LABELS : optional
list of labels to assign to the test
The project name in lower case is always added as a label. Additional labels are assigned depending on the type of test:
executable: for type EXEscript: for type SCRIPTpython: for type PYTHONmpi: if MPIis setopenmp: if OMPis setThis allows selecting tests to run via
ctest -L <regex>or tests to exclude viactest -LE <regex>.- ARGS : optional
- list of arguments to pass to TARGET or COMMAND when running the test
- RESOURCES : optional
- list of files to copy from the test source directory to the test directory
- TEST_DATA : optional
- list of test data files to download
- MPI : optional
Run with MPI using the given number of MPI tasks.
If greater than 1, and
MPIEXECis not available, the test is disabled.- OMP : optional
number of OpenMP threads per MPI task to use.
If set, the environment variable OMP_NUM_THREADS will set. Also, in case of launchers like aprun, the OMP_NUMTHREADS_FLAG will be used.
- ENABLED : optional
- if set to OFF, the test is built but not enabled as a test case
- LIBS : optional
- list of libraries to link against (CMake targets or external libraries)
- INCLUDES : optional
- list of paths to add to include directories
- DEFINITIONS : optional
- list of definitions to add to preprocessor defines
- PERSISTENT : optional
- list of persistent layer object files
- GENERATED : optional
- list of files to mark as generated (sets GENERATED source file property)
- DEPENDS : optional
- list of targets to be built before this target
- TEST_DEPENDS : optional
- list of tests to be run before this one
- CONDITION : optional
- conditional expression which must evaluate to true for this target to be
built (must be valid in a CMake
ifstatement) - PROPERTIES : optional
- custom properties to set on the target
- ENVIRONMENT : optional
- list of environment variables to set in the test environment
- WORKING_DIRECTORY : optional
- directory to switch to before running the test
- CFLAGS : optional
- list of C compiler flags to use for all C source files
- CXXFLAGS : optional
- list of C++ compiler flags to use for all C++ source files
- FFLAGS : optional
- list of Fortran compiler flags to use for all Fortran source files
- LINKER_LANGUAGE : optional
- sets the LINKER_LANGUAGE property on the target