Skip to content
Snippets Groups Projects
Commit e8f46834 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

common code -> macr

parent 8e491937
No related branches found
No related tags found
1 merge request!773new mechanism to steer simulation size in examples and tests, based on command-line argument sim_n
...@@ -9,18 +9,21 @@ file(MAKE_DIRECTORY ${TEST_OUTPUT_DIR_PY_PERSIST}) ...@@ -9,18 +9,21 @@ file(MAKE_DIRECTORY ${TEST_OUTPUT_DIR_PY_PERSIST})
# Test scripts # Test scripts
#################################################################################################### ####################################################################################################
macro(parse_example example)
cmake_path(SET EXAMPLE_SCRIPT NORMALIZE ${EXAMPLES_DIR}/${example}.py)
get_filename_component(EXAMPLE_NAME ${EXAMPLE_SCRIPT} NAME_WE)
get_filename_component(EXAMPLE_SUBDIR ${example} DIRECTORY)
endmacro()
# Run one Python example. # Run one Python example.
# Check whether the example executes, don't check results. # Check whether the example executes, don't check results.
# If there are matplotlib commands, skip plt.show(). # If there are matplotlib commands, skip plt.show().
function(run_example example label) function(run_example example label)
set(script_path ${EXAMPLES_DIR}/${example}.py) parse_example(${example})
get_filename_component(EXAMPLE_NAME ${script_path} NAME_WE)
set(test_name Example.run.${EXAMPLE_NAME}) set(test_name Example.run.${EXAMPLE_NAME})
add_test(NAME ${test_name} add_test(NAME ${test_name}
COMMAND ${CMAKE_COMMAND} -E env COMMAND ${CMAKE_COMMAND} -E env
BA_EXAMPLE_DATA_DIR=${EXAMPLES_DIR}/data BA_EXAMPLE_DATA_DIR=${EXAMPLES_DIR}/data
NOSHOW=TRUE
${Python3_EXECUTABLE} ${TOOL_DIR}/code/batch-plot.py ${Python3_EXECUTABLE} ${TOOL_DIR}/code/batch-plot.py
-s ${script_path} ${TEST_OUTPUT_DIR_PY_EXAMPLES}) -s ${script_path} ${TEST_OUTPUT_DIR_PY_EXAMPLES})
if(NOT label STREQUAL "") if(NOT label STREQUAL "")
...@@ -30,9 +33,7 @@ endfunction() ...@@ -30,9 +33,7 @@ endfunction()
# Run examples that don't plot. # Run examples that don't plot.
function(run_noplot example) function(run_noplot example)
cmake_path(SET EXAMPLE_SCRIPT NORMALIZE ${EXAMPLES_DIR}/${example}.py) parse_example(${example})
get_filename_component(EXAMPLE_NAME ${EXAMPLE_SCRIPT} NAME_WE)
set(test_name Example.exec.${EXAMPLE_NAME}) set(test_name Example.exec.${EXAMPLE_NAME})
add_test(NAME ${test_name} add_test(NAME ${test_name}
COMMAND ${Python3_EXECUTABLE} -B ${EXAMPLE_SCRIPT} COMMAND ${Python3_EXECUTABLE} -B ${EXAMPLE_SCRIPT}
...@@ -41,10 +42,7 @@ endfunction() ...@@ -41,10 +42,7 @@ endfunction()
# Python equality test: run modified example, and compare with reference data of another example # Python equality test: run modified example, and compare with reference data of another example
function(test_equality example reference tolerance) function(test_equality example reference tolerance)
cmake_path(SET EXAMPLE_SCRIPT NORMALIZE ${EXAMPLES_DIR}/${example}.py) parse_example(${example})
get_filename_component(EXAMPLE_NAME ${EXAMPLE_SCRIPT} NAME_WE)
get_filename_component(EXAMPLE_SUBDIR ${example} DIRECTORY)
set(test_name Example.persist.${EXAMPLE_NAME}) set(test_name Example.persist.${EXAMPLE_NAME})
add_test(NAME ${test_name} add_test(NAME ${test_name}
COMMAND ${CMAKE_COMMAND} COMMAND ${CMAKE_COMMAND}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment