VTK  9.0.2
vtkModuleTesting.cmake
Go to the documentation of this file.
1 #[==[.md
2 # `vtkModuleTesting`
3 
4 VTK uses the [ExternalData][] CMake module to handle the data management for
5 its test suite. Test data is only downloaded when a test which requires it is
6 enabled and it is cached so that every build does not need to redownload the
7 same data.
8 
9 To facilitate this workflow, there are a number of CMake functions available in
10 order to indicate that test data is required.
11 
12 [ExternalData]: TODO
13 #]==]
14 
15 include(ExternalData)
16 get_filename_component(_vtkModuleTesting_dir "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY)
17 
18 #[==[.md
19 ## Loading data
20 
21 Data may be downloaded manually using this function:
22 
23 ~~~
24 vtk_module_test_data(<PATHSPEC>...)
25 ~~~
26 
27 This will download data inside of the input data directory for the modules
28 being built at that time (see the `TEST_INPUT_DATA_DIRECTORY` argument of
30 
31 For supported `PATHSPEC` syntax, see the
32 [associated documentation][ExternalData pathspecs] in `ExternalData`. These
33 arguments are already wrapped in the `DATA{}` syntax and are assumed to be
34 relative paths from the input data directory.
35 
36 [ExternalData pathspecs]: TODO
37 #]==]
39  set(data_args)
40  foreach (arg IN LISTS ARGN)
41  if (IS_ABSOLUTE "${arg}")
42  list(APPEND data_args
43  "DATA{${arg}}")
44  else ()
45  list(APPEND data_args
46  "DATA{${_vtk_build_TEST_INPUT_DATA_DIRECTORY}/${arg}}")
47  endif ()
48  endforeach ()
49 
50  ExternalData_Expand_Arguments("${_vtk_build_TEST_DATA_TARGET}" _ ${data_args})
51 endfunction ()
52 
53 #[==[.md
54 ## Creating test executables
55 
56 This function creates an executable from the list of sources passed to it. It
57 is automatically linked to the module the tests are intended for as well as any
58 declared test dependencies of the module.
59 
60 ~~~
61 vtk_module_test_executable(<NAME> <SOURCE>...)
62 ~~~
63 
64 This function is not usually used directly, but instead through the other
65 convenience functions.
66 #]==]
67 function (vtk_module_test_executable name)
68  add_executable("${name}" ${ARGN})
69  get_property(test_depends GLOBAL
70  PROPERTY "_vtk_module_${_vtk_build_test}_test_depends")
71  get_property(test_optional_depends GLOBAL
72  PROPERTY "_vtk_module_${_vtk_build_test}_test_optional_depends")
73  set(optional_depends_flags)
74  foreach (test_optional_depend IN LISTS test_optional_depends)
75  if (TARGET "${test_optional_depend}")
76  list(APPEND test_depends
77  "${test_optional_depend}")
78  set(test_optional_depend_flag "1")
79  else ()
80  set(test_optional_depend_flag "0")
81  endif ()
82  string(REPLACE "::" "_" safe_test_optional_depend "${test_optional_depend}")
83  list(APPEND optional_depends_flags
84  "VTK_MODULE_ENABLE_${safe_test_optional_depend}=${test_optional_depend_flag}")
85  endforeach ()
86 
87  target_link_libraries("${name}"
88  PRIVATE
89  "${_vtk_build_test}"
90  ${test_depends})
91  target_compile_definitions("${name}"
92  PRIVATE
93  ${optional_depends_flags})
94 
95  vtk_module_autoinit(
96  TARGETS "${name}"
97  MODULES "${_vtk_build_test}"
98  ${test_depends})
99 endfunction ()
100 
101 #[==[.md
102 ## Test name parsing
103 
104 Test names default to using the basename of the filename which contains the
105 test. Two tests may share the same file by prefixing with a custom name for the
106 test and a comma.
107 
108 The two parsed syntaxes are:
109 
110  - `CustomTestName,TestFile`
111  - `TestFile`
112 
113 Note that `TestFile` should already have had its extension stripped (usually
114 done by `_vtk_test_parse_args`).
115 
116 In general, the name of a test will be `<EXENAME>-<TESTNAME>`, however, by
117 setting `vtk_test_prefix`, the test name will instead be
118 `<EXENAME>-<PREFIX><TESTNAME>`.
119 #]==]
120 
121 #[==[.md INTERNAL
122 This function parses the name from a testspec. The calling scope has
123 `test_name` and `test_file` variables set in it.
124 
125 ~~~
126 _vtk_test_parse_name(<TESTSPEC>)
127 ~~~
128 #]==]
129 function (_vtk_test_parse_name name)
130  if (name AND name MATCHES "^([^,]*),(.*)$")
131  set(test_name "${CMAKE_MATCH_1}" PARENT_SCOPE)
132  set(test_file "${CMAKE_MATCH_2}" PARENT_SCOPE)
133  else ()
134  set(test_name "${name}" PARENT_SCOPE)
135  set(test_file "${name}" PARENT_SCOPE)
136  endif ()
137 endfunction ()
138 
139 #[==[.md
140 ## Test function arguments
141 
142 Each test is specified using one of the two following syntaxes
143 
144  - `<NAME>.<SOURCE_EXT>`
145  - `<NAME>.<SOURCE_EXT>,<OPTIONS>`
146 
147 Where `NAME` is a valid test name. If present, the specified `OPTIONS` are only
148 for the associated test. The expected extension is specified by the associated
149 test function.
150 #]==]
151 
152 #[==[.md INTERNAL
153 Given a list of valid "options", this function will parse out a the following
154 variables:
155 
156  - `args`: Unrecognized arguments. These should be interpreted as arguments
157  that should be passed on the command line to all tests in this parse group.
158  - `options`: Options specified globally (for all tests in this group).
159  - `names`: A list containing all named tests. These should be parsed by
160  `_vtk_test_parse_name`.
161  - `_<NAME>_options`: Options specific to a certain test.
162 
163 ~~~
164 _vtk_test_parse_args(<OPTIONS> <SOURCE_EXT> <ARG>...)
165 ~~~
166 
167 In order to be recognized as a source file, the `SOURCE_EXT` must be used.
168 Without it, all non-option arguments are placed into `args`. Each test is
169 parsed out matching these:
170 #]==]
171 function (_vtk_test_parse_args options source_ext)
172  set(global_options)
173  set(names)
174  set(args)
175 
176  foreach (arg IN LISTS ARGN)
177  set(handled 0)
178  foreach (option IN LISTS options)
179  if (arg STREQUAL option)
180  list(APPEND global_options "${option}")
181  set(handled 1)
182  break ()
183  endif ()
184  endforeach ()
185  if (handled)
186  # Do nothing.
187  elseif (source_ext AND arg MATCHES "^([^.]*)\\.${source_ext},?(.*)$")
188  set(name "${CMAKE_MATCH_1}")
189  string(REPLACE "," ";" "_${name}_options" "${CMAKE_MATCH_2}")
190  list(APPEND names "${name}")
191  else ()
192  list(APPEND args "${arg}")
193  endif ()
194  endforeach ()
195 
196  foreach (name IN LISTS names)
197  set("_${name}_options" "${_${name}_options}"
198  PARENT_SCOPE)
199  endforeach ()
200  set(options "${global_options}"
201  PARENT_SCOPE)
202  set(names "${names}"
203  PARENT_SCOPE)
204  set(args "${args}"
205  PARENT_SCOPE)
206 endfunction ()
207 
208 #[==[.md INTERNAL
209 For handling global option settings, this function sets variables in the
210 calling scoped named `<PREFIX><OPTION>` to either `0` or `1` if the option is
211 present in the remaining argument list.
212 
213 ~~~
214 _vtk_test_set_options(<OPTIONS> <PREFIX> <ARG>...)
215 ~~~
216 
217 Additionally, a non-`0` default for a given option may be specified by a
218 variable with the same name as the option and specifying a prefix for the
219 output variables.
220 #]==]
221 function (_vtk_test_set_options options prefix)
222  foreach (option IN LISTS options)
223  set(default 0)
224  if (prefix)
225  set(default "${${option}}")
226  endif ()
227  set("${prefix}${option}" "${default}"
228  PARENT_SCOPE)
229  endforeach ()
230  foreach (option IN LISTS ARGN)
231  set("${prefix}${option}" 1
232  PARENT_SCOPE)
233  endforeach ()
234 endfunction ()
235 
236 # If set, use the maximum number of processors for tests. Otherwise, just use 1
237 # processor by default.
238 set(VTK_MPI_NUMPROCS "2" CACHE STRING
239  "Number of processors available to run parallel tests.")
240 # Hide the variable if we don't have `MPIEXEC_EXECUTABLE` anyways.
241 if (MPIEXEC_EXECUTABLE)
242  set(_vtk_mpi_max_numprocs_type STRING)
243 else ()
244  set(_vtk_mpi_max_numprocs_type INTERNAL)
245 endif ()
246 set_property(CACHE VTK_MPI_NUMPROCS
247  PROPERTY
248  TYPE "${_vtk_mpi_max_numprocs_type}")
249 
250 #[==[.md
251 ## C++ tests
252 
253 This function declares C++ tests. Source files are required to use the `cxx`
254 extension.
255 
256 ~~~
257 vtk_add_test_cxx(<EXENAME> <VARNAME> <ARG>...)
258 ~~~
259 
260 Each argument should be either an option, a test specification, or it is passed
261 as flags to all tests declared in the group. The list of tests is set in the
262 `<VARNAME>` variable in the calling scope.
263 
264 Options:
265 
266  - `NO_DATA`: The test does not need to know the test input data directory. If
267  it does, it is passed on the command line via the `-D` flag.
268  - `NO_VALID`: The test does not have a valid baseline image. If it does, the
269  baseline is assumed to be in `../Data/Baseline/<NAME>.png` relative to the
270  current source directory. If alternate baseline images are required,
271  `<NAME>` may be suffixed by `_1`, `_2`, etc. The valid image is passed via
272  the `-V` flag.
273  - `NO_OUTPUT`: The test does not need to write out any data to the
274  filesystem. If it does, a directory which may be written to is passed via
275  the `-T` flag.
276 
277 Additional flags may be passed to tests using the `${_vtk_build_test}_ARGS`
278 variable or the `<NAME>_ARGS` variable.
279 #]==]
280 function (vtk_add_test_cxx exename _tests)
281  set(cxx_options
282  NO_DATA
283  NO_VALID
284  NO_OUTPUT)
285  _vtk_test_parse_args("${cxx_options}" "cxx" ${ARGN})
286  _vtk_test_set_options("${cxx_options}" "" ${options})
287 
288  set(_vtk_fail_regex "(\n|^)ERROR: " "instance(s)? still around")
289 
290  foreach (name IN LISTS names)
291  _vtk_test_set_options("${cxx_options}" "local_" ${_${name}_options})
292  _vtk_test_parse_name("${name}")
293 
294  set(_D "")
295  if (NOT local_NO_DATA)
296  set(_D -D "${_vtk_build_TEST_OUTPUT_DATA_DIRECTORY}")
297  endif ()
298 
299  set(_T "")
300  if (NOT local_NO_OUTPUT)
301  set(_T -T "${_vtk_build_TEST_OUTPUT_DIRECTORY}")
302  endif ()
303 
304  set(_V "")
305  if (NOT local_NO_VALID)
306  set(_V -V "DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/${test_name}.png,:}")
307  endif ()
308 
309  ExternalData_add_test("${_vtk_build_TEST_DATA_TARGET}"
310  NAME "${_vtk_build_test}Cxx-${vtk_test_prefix}${test_name}"
311  COMMAND "${exename}"
312  "${test_file}"
313  ${args}
314  ${${_vtk_build_test}_ARGS}
315  ${${name}_ARGS}
316  ${_D} ${_T} ${_V})
317  set_tests_properties("${_vtk_build_test}Cxx-${vtk_test_prefix}${test_name}"
318  PROPERTIES
319  LABELS "${_vtk_build_test_labels}"
320  FAIL_REGULAR_EXPRESSION "${_vtk_fail_regex}"
321  # This must match VTK_SKIP_RETURN_CODE in vtkTestingObjectFactory.h
322  SKIP_RETURN_CODE 125
323  )
324 
325  list(APPEND ${_tests} "${test_file}")
326  endforeach ()
327 
328  set("${_tests}" ${${_tests}} PARENT_SCOPE)
329 endfunction ()
330 
331 #[==[.md
332 ### MPI tests
333 
334 This function declares C++ tests which should be run under an MPI environment.
335 Source files are required to use the `cxx` extension.
336 
337 ~~~
338 vtk_add_test_mpi(<EXENAME> <VARNAME> <ARG>...)
339 ~~~
340 
341 Each argument should be either an option, a test specification, or it is passed
342 as flags to all tests declared in the group. The list of tests is set in the
343 `<VARNAME>` variable in the calling scope.
344 
345 Options:
346 
347  - `TESTING_DATA`
348  - `NO_VALID`: The test does not have a valid baseline image. If it does, the
349  baseline is assumed to be in `../Data/Baseline/<NAME>.png` relative to the
350  current source directory. If alternate baseline images are required,
351  `<NAME>` may be suffixed by `_1`, `_2`, etc. The valid image is passed via
352  the `-V` flag.
353 
354 Each test is run using the number of processors specified by the following
355 variables (using the first one which is set):
356 
357  - `<NAME>_NUMPROCS`
358  - `<EXENAME>_NUMPROCS`
359  - `VTK_MPI_NUMPROCS` (defaults to `2`)
360 
361 Additional flags may be passed to tests using the `${_vtk_build_test}_ARGS`
362 variable or the `<NAME>_ARGS` variable.
363 #]==]
364 function (vtk_add_test_mpi exename _tests)
365  set(mpi_options
366  TESTING_DATA
367  NO_VALID
368  )
369  _vtk_test_parse_args("${mpi_options}" "cxx" ${ARGN})
370  _vtk_test_set_options("${mpi_options}" "" ${options})
371 
372  set(_vtk_fail_regex "(\n|^)ERROR: " "instance(s)? still around")
373 
374  set(default_numprocs ${VTK_MPI_NUMPROCS})
375  if (${exename}_NUMPROCS)
376  set(default_numprocs ${${exename}_NUMPROCS})
377  endif ()
378 
379  foreach (name IN LISTS names)
380  _vtk_test_set_options("${mpi_options}" "local_" ${_${name}_options})
381  _vtk_test_parse_name(${name})
382 
383  set(_D "")
384  set(_T "")
385  set(_V "")
386  if (local_TESTING_DATA)
387  set(_D -D "${_vtk_build_TEST_OUTPUT_DATA_DIRECTORY}")
388  set(_T -T "${_vtk_build_TEST_OUTPUT_DIRECTORY}")
389  set(_V "")
390  if (NOT local_NO_VALID)
391  set(_V -V "DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/${name}.png,:}")
392  endif ()
393  endif ()
394 
395  set(numprocs ${default_numprocs})
396  if (${name}_NUMPROCS)
397  set(numprocs "${${name}_NUMPROCS}")
398  endif ()
399 
400  ExternalData_add_test("${_vtk_build_TEST_DATA_TARGET}"
401  NAME "${_vtk_build_test}Cxx-MPI-${vtk_test_prefix}${test_name}"
402  COMMAND "${MPIEXEC_EXECUTABLE}"
403  "${MPIEXEC_NUMPROC_FLAG}" "${numprocs}"
404  ${MPIEXEC_PREFLAGS}
405  "$<TARGET_FILE:${exename}>"
406  "${test_file}"
407  ${_D} ${_T} ${_V}
408  ${args}
409  ${${_vtk_build_test}_ARGS}
410  ${${name}_ARGS}
411  ${MPIEXEC_POSTFLAGS})
412  set_tests_properties("${_vtk_build_test}Cxx-MPI-${vtk_test_prefix}${test_name}"
413  PROPERTIES
414  LABELS "${_vtk_build_test_labels}"
415  PROCESSORS "${numprocs}"
416  FAIL_REGULAR_EXPRESSION "${_vtk_fail_regex}"
417  # This must match VTK_SKIP_RETURN_CODE in vtkTestingObjectFactory.h"
418  SKIP_RETURN_CODE 125
419  )
420  set_property(TEST "${_vtk_build_test}Cxx-MPI-${vtk_test_prefix}${test_name}" APPEND
421  PROPERTY
422  REQUIRED_FILES "$<TARGET_FILE:${exename}>")
423  list(APPEND ${_tests} "${test_file}")
424  endforeach ()
425 
426  set(${_tests} ${${_tests}} PARENT_SCOPE)
427 endfunction ()
428 
429 #[==[.md
430 ### C++ test executable
431 
432 ~~~
433 vtk_test_cxx_executable(<EXENAME> <VARNAME> [RENDERING_FACTORY] [<SRC>...])
434 ~~~
435 
436 Creates an executable named `EXENAME` which contains the tests listed in the
437 variable named in the `VARNAME` argument. The `EXENAME` must match the
438 `EXENAME` passed to the test declarations when building the list of tests.
439 
440 If `RENDERING_FACTORY` is provided, VTK's rendering factories are initialized
441 during the test.
442 
443 Any additional arguments are added as additional sources for the executable.
444 #]==]
445 function (vtk_test_cxx_executable exename _tests)
446  set(exe_options
447  RENDERING_FACTORY)
448  _vtk_test_parse_args("${exe_options}" "" ${ARGN})
449  _vtk_test_set_options("${exe_options}" "" ${options})
450 
451  if (NOT ${_tests})
452  # No tests -> no need for an executable.
453  return()
454  endif ()
455 
456  if (RENDERING_FACTORY)
457  include("${_vtkModuleTesting_dir}/vtkTestingRenderingDriver.cmake")
458  set(test_driver vtkTestingObjectFactory.h)
459  else ()
460  include("${_vtkModuleTesting_dir}/vtkTestingDriver.cmake")
461  set(test_driver vtkTestDriver.h)
462  endif ()
463 
464  set(extra_sources ${args})
465 
466  create_test_sourcelist(test_sources "${exename}.cxx" ${${_tests}}
467  EXTRA_INCLUDE "${test_driver}")
468 
469  if (_vtk_build_test)
470  vtk_module_test_executable("${exename}" ${test_sources} ${extra_sources})
471  else ()
472  message(FATAL_ERROR "_vtk_build_test is not set!")
473  endif ()
474 endfunction ()
475 
476 #[==[.md INTERNAL
477 MPI executables used to have their own test executable function. This is no
478 longer necessary and is deprecated. Instead, `vtk_test_cxx_executable` should
479 be used instead.
480 #]==]
481 function (vtk_test_mpi_executable exename _tests)
482  message(DEPRECATION
483  "The `vtk_test_mpi_executable` function is deprecated; use "
484  "`vtk_test_cxx_executable` instead.")
485  vtk_test_cxx_executable("${exename}" "${_tests}" ${ARGN})
486 endfunction ()
487 
488 #[==[.md
489 ## Python tests
490 
491 This function declares Python tests. Test files are required to use the `py`
492 extension.
493 
494 ~~~
495 vtk_add_test_python(<EXENAME> <VARNAME> <ARG>...)
496 ~~~
497 #]==]
498 
499 #[==[.md INTERNAL
500 If the `_vtk_testing_python_exe` variable is not set, the `vtkpython` binary is
501 used by default. Additional arguments may be passed in this variable as well.
502 #]==]
503 
504 #[==[.md
505 Options:
506 
507  - `NO_DATA`
508  - `NO_VALID`
509  - `NO_OUTPUT`
510  - `NO_RT`
511  - `JUST_VALID`
512 
513 Each argument should be either an option, a test specification, or it is passed
514 as flags to all tests declared in the group. The list of tests is set in the
515 `<VARNAME>` variable in the calling scope.
516 
517 Options:
518 
519  - `NO_DATA`: The test does not need to know the test input data directory. If
520  it does, it is passed on the command line via the `-D` flag.
521  - `NO_OUTPUT`: The test does not need to write out any data to the
522  filesystem. If it does, a directory which may be written to is passed via
523  the `-T` flag.
524  - `NO_VALID`: The test does not have a valid baseline image. If it does, the
525  baseline is assumed to be in `../Data/Baseline/<NAME>.png` relative to the
526  current source directory. If alternate baseline images are required,
527  `<NAME>` may be suffixed by `_1`, `_2`, etc. The valid image is passed via
528  the `-V` flag.
529  - `NO_RT`: If `NO_RT` is specified, `-B` is passed instead of `-V`, only
530  providing a baseline dir, assuming `NO_VALID` is not specified.
531  - `DIRECT_DATA` : If `DIRECT_DATA` is specified, the baseline path will be provided
532  as is, without the use of ExternalData_add_test.
533  - `JUST_VALID`: Only applies when both `NO_VALID` and `NO_RT` are not
534  present. If it is not specified, `-A` is passed with path to the directory
535  of the `vtkTclTest2Py` Python package and the test is run via the
536  `rtImageTest.py` script. Note that this currently only works when building
537  against a VTK build tree; the VTK install tree does not include this script
538  or its associated Python package.
539 
540 Additional flags may be passed to tests using the `${_vtk_build_test}_ARGS`
541 variable or the `<NAME>_ARGS` variable.
542 
543 Note that the `vtkTclTest2Py` support will eventually be removed. It is a
544 legacy of the conversion of many tests from Tcl to Python.
545 #]==]
546 function (vtk_add_test_python)
547  if (NOT _vtk_testing_python_exe)
548  set(_vtk_testing_python_exe "$<TARGET_FILE:VTK::vtkpython>")
549  endif ()
550  set(python_options
551  NO_DATA
552  NO_VALID
553  NO_OUTPUT
554  NO_RT
555  DIRECT_DATA
556  JUST_VALID
557  )
558  _vtk_test_parse_args("${python_options}" "py" ${ARGN})
559  _vtk_test_set_options("${python_options}" "" ${options})
560 
561  set(_vtk_fail_regex "(\n|^)ERROR: " "instance(s)? still around")
562 
563  foreach (name IN LISTS names)
564  _vtk_test_set_options("${python_options}" "local_" ${_${name}_options})
565  _vtk_test_parse_name(${name})
566 
567  set(_D "")
568  if (NOT local_NO_DATA)
569  set(_D -D "${_vtk_build_TEST_OUTPUT_DATA_DIRECTORY}")
570  endif ()
571 
572  set(rtImageTest "")
573  set(_B "")
574  set(_V "")
575  set(_A "")
576  if (NOT local_NO_VALID)
577  if (local_NO_RT)
578  if (local_DIRECT_DATA)
579  set(_B -B "${CMAKE_CURRENT_SOURCE_DIR}/Data/Baseline/")
580  else ()
581  set(_B -B "DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/,REGEX:${test_name}(-.*)?(_[0-9]+)?.png}")
582  endif()
583  else ()
584  if (local_DIRECT_DATA)
585  set(_V -V "${CMAKE_CURRENT_SOURCE_DIR}/Data/Baseline/${test_name}.png")
586  else ()
587  set(_V -V "DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/${test_name}.png,:}")
588  endif()
589  if (NOT local_JUST_VALID)
590  # TODO: This should be fixed to also work from an installed VTK.
591  set(rtImageTest "${VTK_SOURCE_DIR}/Utilities/vtkTclTest2Py/rtImageTest.py")
592  set(_A -A "${VTK_SOURCE_DIR}/Utilities/vtkTclTest2Py")
593  endif ()
594  endif ()
595  endif ()
596 
597  set(_T "")
598  if (NOT local_NO_OUTPUT)
599  set(_T -T "${_vtk_build_TEST_OUTPUT_DIRECTORY}")
600  endif ()
601 
602  if (NOT _vtk_build_TEST_FILE_DIRECTORY)
603  set(_vtk_build_TEST_FILE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
604  endif()
605 
606  set(testArgs NAME "${_vtk_build_test}Python${_vtk_test_python_suffix}-${vtk_test_prefix}${test_name}"
607  COMMAND ${_vtk_test_python_pre_args}
608  "${_vtk_testing_python_exe}" ${_vtk_test_python_args} --enable-bt
609  ${rtImageTest}
610  "${_vtk_build_TEST_FILE_DIRECTORY}/${test_file}.py"
611  ${args}
612  ${${_vtk_build_test}_ARGS}
613  ${${name}_ARGS}
614  ${_D} ${_B} ${_T} ${_V} ${_A})
615 
616  if (local_DIRECT_DATA)
617  add_test(${testArgs})
618  else ()
619  ExternalData_add_test("${_vtk_build_TEST_DATA_TARGET}" ${testArgs})
620  endif()
621 
622  set_tests_properties("${_vtk_build_test}Python${_vtk_test_python_suffix}-${vtk_test_prefix}${test_name}"
623  PROPERTIES
624  LABELS "${_vtk_build_test_labels}"
625  FAIL_REGULAR_EXPRESSION "${_vtk_fail_regex}"
626  # This must match the skip() function in vtk/test/Testing.py"
627  SKIP_RETURN_CODE 125
628  )
629  endforeach ()
630 endfunction ()
631 
632 #[==[.md
633 ### MPI tests
634 
635 A small wrapper around `vtk_add_test_python` which adds support for running
636 MPI-aware tests written in Python.
637 
638 The `$<module library name>_NUMPROCS` variable may be used to use a non-default
639 number of processors for a test.
640 
641 This forces running with the `pvtkpython` executable.
642 #]==]
643 function (vtk_add_test_python_mpi)
644  set(_vtk_test_python_suffix "-MPI")
645 
646  set(numprocs "${VTK_MPI_NUMPROCS}")
647  _vtk_module_get_module_property("${_vtk_build_test}"
648  PROPERTY "library_name"
649  VARIABLE _vtk_test_python_library_name)
650  if (${_vtk_test_python_library_name}_NUMPROCS)
651  set(numprocs "${${_vtk_test_python_library_name}_NUMPROCS}")
652  endif ()
653 
654  set(_vtk_test_python_pre_args
655  "${MPIEXEC_EXECUTABLE}"
656  "${MPIEXEC_NUMPROC_FLAG}" "${numprocs}"
657  ${MPIEXEC_PREFLAGS})
658 
659  if (NOT _vtk_testing_python_exe)
660  set(_vtk_testing_python_exe "$<TARGET_FILE:VTK::pvtkpython>")
661  endif ()
662  vtk_add_test_python(${ARGN})
663 endfunction ()
Tests instantiations of the vtkNew class template.
function vtk_module_build()
Build modules and kits.
@ order
Definition: vtkX3D.h:446
@ time
Definition: vtkX3D.h:503
@ documentation
Definition: vtkX3D.h:334
@ enabled
Definition: vtkX3D.h:265
@ name
Definition: vtkX3D.h:225
@ data
Definition: vtkX3D.h:321
function vtk_test_cxx_executable(exename, _tests)
.md
function vtk_module_test_data()
.md