@@ -270,15 +270,26 @@ add_test(NAME python_tests
270
270
--start-directory "${CMAKE_CURRENT_SOURCE_DIR} /tests"
271
271
--verbose
272
272
)
273
+
274
+ # List the examples we want to test. Some examples might run too long for
275
+ # testing, or might require additional libraries.
276
+ # Leave off the .py extension; here, we are listing module names.
277
+ set (PYTHON_EXAMPLES_UNITTEST_ARGS
278
+ build_simple_arm_model
279
+ extend_OpenSim_Vec3_class
280
+ posthoc_StatesTrajectory_example
281
+ wiring_inputs_and_outputs_with_TableReporter
282
+ )
273
283
# Similar as above, but for the example files. These files aren't named as
274
284
# test_*.py, so we must specify a more general search pattern.
275
285
add_test (NAME python_examples
276
286
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /$<CONFIG>"
277
- COMMAND "${PYTHON_EXECUTABLE} " -m unittest discover
278
- --start-directory "${CMAKE_CURRENT_SOURCE_DIR} /examples"
279
- --pattern *.py
287
+ COMMAND "${PYTHON_EXECUTABLE} " -m unittest
288
+ ${PYTHON_EXAMPLES_UNITTEST_ARGS}
280
289
--verbose
281
290
)
291
+ set_tests_properties (python_examples PROPERTIES
292
+ ENVIRONMENT PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR}/examples )
282
293
283
294
if (WIN32 )
284
295
# On Windows, CMake cannot use RPATH to hard code the location of libraries
@@ -288,7 +299,7 @@ if(WIN32)
288
299
# want to accidentally use a different OpenSim build/installation somewhere
289
300
# on the machine.
290
301
foreach (folder tests examples )
291
- set_tests_properties ( python_${folder} PROPERTIES ENVIRONMENT
302
+ set_property ( TEST python_${folder} APPEND PROPERTY ENVIRONMENT
292
303
"PATH=${CMAKE_BINARY_DIR} /$<CONFIG>" )
293
304
endforeach ()
294
305
endif ()
0 commit comments