Commit 123bc05a authored by David Thompson's avatar David Thompson
Browse files

Move duplicated code out of python test dirs.

Finding the python interpreter and preparing the test environment
should happen once at the beginning of the configuration step.
parent 3cf262fe
......@@ -195,6 +195,25 @@ endif()
################################################################################
if(SMTK_BUILD_PYTHON_WRAPPINGS)
include(UseShiboken)
find_package(PythonInterp 2.7 REQUIRED)
# Set up environment variables needed to import the python modules for tests.
if (PYTHONINTERP_FOUND AND SMTK_ENABLE_TESTING)
get_filename_component(SHIBOKEN_LIBRARY_PATH ${SHIBOKEN_LIBRARY} PATH)
set(LIB_ENV_VAR "")
if(APPLE AND UNIX)
set(LIB_ENV_VAR "DYLD_FALLBACK_LIBRARY_PATH=${SHIBOKEN_LIBRARY_PATH}:${LIBRARY_OUTPUT_PATH}")
elseif(UNIX)
set(LIB_ENV_VAR "LD_LIBRARY_PATH=${SHIBOKEN_LIBRARY_PATH}:${LIBRARY_OUTPUT_PATH}")
endif()
set(SHIBOKEN_SMTK_PYTHON "")
if(UNIX)
set(SHIBOKEN_SMTK_PYTHON "${CMAKE_BINARY_DIR}:${SHIBOKEN_LIBRARY_PATH}")
else() #windows
set(SHIBOKEN_SMTK_PYTHON "${CMAKE_BINARY_DIR};${SHIBOKEN_LIBRARY_PATH}")
endif()
endif()
#message("${LIB_ENV_VAR} PYTHONPATH=${SIBOKEN_SMTK_PYTHON}")
#message("${SHIBOKEN_LIBRARY_PATH}")
endif()
################################################################################
......
find_package( PythonInterp 2.7 )
# Additional tests that require SMTK_DATA_DIR
set(smtkModelPythonDataTests
copyDefinitionTest
copyAttributeTest
)
add_test(associationTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/associationTest.py)
add_test(basicAttributeTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/basicAttributeTest.py)
add_test(basicAttributeDefinitionTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/basicAttributeDefinitionTest.py)
add_test(basicAttributeDerivationTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/basicAttributeDerivationTest.py)
add_test(basicAttributeXMLWriterTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/basicAttributeXMLWriterTest.py dummypy.sbi)
add_test(expressintTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/expressionTest.py)
add_test(expressionTest2Py ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/expressionTest2.py)
add_test(attributeAutoNamingTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/attributeAutoNamingTest.py)
add_test(attributeReferencingTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/attributeReferencingTest.py)
add_test(categoryTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/categoryTest.py)
add_test(attributeFindItemTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/attributeFindItemTest.py)
add_test(definitionDefaultValueTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/definitionDefaultValueTest.py dummy.sbt)
set_tests_properties(
associationTestPy basicAttributeTestPy basicAttributeDefinitionTestPy
basicAttributeDerivationTestPy basicAttributeXMLWriterTestPy
expressintTestPy expressionTest2Py definitionDefaultValueTestPy
attributeAutoNamingTestPy attributeAutoNamingTestPy
attributeReferencingTestPy categoryTestPy attributeFindItemTestPy
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
if( PYTHONINTERP_FOUND )
set(LIB_ENV_VAR "")
if(APPLE AND UNIX)
set(LIB_ENV_VAR "DYLD_LIBRARY_PATH=${SHIBOKEN_LIBRARY_PATH}")
elseif(UNIX)
set(LIB_ENV_VAR "LD_LIBRARY_PATH=${SHIBOKEN_LIBRARY_PATH}")
endif()
set(SIBOKEN_SMTK_PYTHON "")
if(UNIX)
set(SHIBOKEN_SMTK_PYTHON "${CMAKE_BINARY_DIR}:${SHIBOKEN_LIBRARY_PATH}")
else() #windows
set(SHIBOKEN_SMTK_PYTHON "${CMAKE_BINARY_DIR};${SHIBOKEN_LIBRARY_PATH}")
endif()
#message("${LIB_ENV_VAR} PYTHONPATH=${SIBOKEN_SMTK_PYTHON}")
#message("${SHIBOKEN_LIBRARY_PATH}")
add_test(associationTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/associationTest.py)
add_test(basicAttributeTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/basicAttributeTest.py)
add_test(basicAttributeDefinitionTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/basicAttributeDefinitionTest.py)
add_test(basicAttributeDerivationTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/basicAttributeDerivationTest.py)
add_test(basicAttributeXMLWriterTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/basicAttributeXMLWriterTest.py dummypy.sbi)
add_test(expressintTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/expressionTest.py)
add_test(expressionTest2Py ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/expressionTest2.py)
add_test(attributeAutoNamingTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/attributeAutoNamingTest.py)
add_test(attributeReferencingTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/attributeReferencingTest.py)
add_test(categoryTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/categoryTest.py)
add_test(attributeFindItemTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/attributeFindItemTest.py)
add_test(definitionDefaultValueTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/definitionDefaultValueTest.py dummy.sbt)
set_tests_properties( associationTestPy basicAttributeTestPy basicAttributeDefinitionTestPy
basicAttributeDerivationTestPy basicAttributeXMLWriterTestPy
expressintTestPy expressionTest2Py definitionDefaultValueTestPy
attributeAutoNamingTestPy attributeAutoNamingTestPy
attributeReferencingTestPy categoryTestPy attributeFindItemTestPy
PROPERTIES ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}" )
if (SMTK_DATA_DIR AND EXISTS ${SMTK_DATA_DIR}/ReadMe.mkd)
foreach (test ${smtkModelPythonDataTests})
add_test(${test}Py
${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/${test}.py
${SMTK_DATA_DIR})
set_tests_properties(${test}Py
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
endif()
else()
message("could not find python interp")
if (SMTK_DATA_DIR AND EXISTS ${SMTK_DATA_DIR}/ReadMe.mkd)
foreach (test ${smtkModelPythonDataTests})
add_test(
${test}Py
${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/${test}.py
${SMTK_DATA_DIR})
set_tests_properties(${test}Py
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
endif()
......@@ -9,44 +9,23 @@ set(smtkCGMBridgePythonDataTests
cgmLoadFile
)
find_package( PythonInterp 2.7 )
foreach (test ${smtkCGMBridgePythonTests})
add_test(${test}Py ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${test}.py)
set_tests_properties(${test}Py
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
if( PYTHONINTERP_FOUND )
set(LIB_ENV_VAR "")
if(APPLE AND UNIX)
set(LIB_ENV_VAR "DYLD_LIBRARY_PATH=${SHIBOKEN_LIBRARY_PATH}")
elseif(UNIX)
set(LIB_ENV_VAR "LD_LIBRARY_PATH=${SHIBOKEN_LIBRARY_PATH}")
endif()
set(SHIBOKEN_SMTK_PYTHON "")
if(UNIX)
set(SHIBOKEN_SMTK_PYTHON "${CMAKE_BINARY_DIR}:${SHIBOKEN_LIBRARY_PATH}")
else() #windows
set(SHIBOKEN_SMTK_PYTHON "${CMAKE_BINARY_DIR};${SHIBOKEN_LIBRARY_PATH}")
endif()
foreach (test ${smtkCGMBridgePythonTests})
add_test(${test}Py ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${test}.py)
if (SMTK_DATA_DIR AND EXISTS ${SMTK_DATA_DIR}/ReadMe.mkd)
foreach (test ${smtkCGMBridgePythonDataTests})
add_test(${test}Py
${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/${test}.py
${SMTK_DATA_DIR})
set_tests_properties(${test}Py
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
if (SMTK_DATA_DIR AND EXISTS ${SMTK_DATA_DIR}/ReadMe.mkd)
foreach (test ${smtkCGMBridgePythonDataTests})
add_test(${test}Py
${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/${test}.py
${SMTK_DATA_DIR})
set_tests_properties(${test}Py
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
endif()
else()
message("could not find python interp")
endif()
add_subdirectory(cxx)
add_subdirectory(python)
if(SMTK_BUILD_PYTHON_WRAPPINGS AND Shiboken_FOUND)
add_subdirectory(python)
endif()
add_subdirectory(cxx)
add_subdirectory(python)
if(SMTK_BUILD_PYTHON_WRAPPINGS AND Shiboken_FOUND)
add_subdirectory(python)
endif()
......@@ -9,44 +9,23 @@ set(smtkModelPythonDataTests
modelAttributes
)
find_package( PythonInterp 2.7 )
foreach (test ${smtkModelPythonTests})
add_test(${test}Py ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${test}.py)
set_tests_properties(${test}Py
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
if( PYTHONINTERP_FOUND )
set(LIB_ENV_VAR "")
if(APPLE AND UNIX)
set(LIB_ENV_VAR "DYLD_LIBRARY_PATH=${SHIBOKEN_LIBRARY_PATH}")
elseif(UNIX)
set(LIB_ENV_VAR "LD_LIBRARY_PATH=${SHIBOKEN_LIBRARY_PATH}")
endif()
set(SHIBOKEN_SMTK_PYTHON "")
if(UNIX)
set(SHIBOKEN_SMTK_PYTHON "${CMAKE_BINARY_DIR}:${SHIBOKEN_LIBRARY_PATH}")
else() #windows
set(SHIBOKEN_SMTK_PYTHON "${CMAKE_BINARY_DIR};${SHIBOKEN_LIBRARY_PATH}")
endif()
foreach (test ${smtkModelPythonTests})
add_test(${test}Py ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${test}.py)
if (SMTK_DATA_DIR AND EXISTS ${SMTK_DATA_DIR}/ReadMe.mkd)
foreach (test ${smtkModelPythonDataTests})
add_test(${test}Py
${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/${test}.py
${SMTK_DATA_DIR})
set_tests_properties(${test}Py
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
if (SMTK_DATA_DIR AND EXISTS ${SMTK_DATA_DIR}/ReadMe.mkd)
foreach (test ${smtkModelPythonDataTests})
add_test(${test}Py
${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/${test}.py
${SMTK_DATA_DIR})
set_tests_properties(${test}Py
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
endif()
else()
message("could not find python interp")
endif()
add_subdirectory(cxx)
add_subdirectory(python)
if(SMTK_BUILD_PYTHON_WRAPPINGS AND Shiboken_FOUND)
add_subdirectory(python)
endif()
find_package( PythonInterp 2.7 )
if( PYTHONINTERP_FOUND )
set(LIB_ENV_VAR "")
if(APPLE AND UNIX)
set(LIB_ENV_VAR "DYLD_LIBRARY_PATH=${SHIBOKEN_LIBRARY_PATH}")
elseif(UNIX)
set(LIB_ENV_VAR "LD_LIBRARY_PATH=${SHIBOKEN_LIBRARY_PATH}")
endif()
set(SHIBOKEN_SMTK_PYTHON "")
if(UNIX)
set(SHIBOKEN_SMTK_PYTHON "${CMAKE_BINARY_DIR}:${SHIBOKEN_LIBRARY_PATH}")
else() #windows
set(SHIBOKEN_SMTK_PYTHON "${CMAKE_BINARY_DIR};${SHIBOKEN_LIBRARY_PATH}")
endif()
#message("${LIB_ENV_VAR} PYTHONPATH=${SIBOKEN_SMTK_PYTHON}")
#message("${SHIBOKEN_LIBRARY_PATH}")
add_test(basicViewWriterTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/basicViewWriterTest.py)
set_tests_properties( basicViewWriterTestPy
PROPERTIES ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}" )
else()
message("could not find python interp")
endif()
add_test(basicViewWriterTestPy ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/basicViewWriterTest.py)
set_tests_properties(basicViewWriterTestPy
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment