Commit 9ddaf7bc authored by David Thompson's avatar David Thompson
Browse files

Fix `PYTHONPATH` for VTK image tests.

SMTK currently requires a ParaView build directory, at least on
Mac OS X, because ParaView does not install properly.
Fix the `PYTHONPATH` for testing to include the `lib/site-packages`
directory so that `import vtk` can work and image-based tests run.
parent c43be88d
......@@ -219,11 +219,20 @@ if(SMTK_ENABLE_PYTHON_WRAPPING)
set(LIB_ENV_VAR "")
if(APPLE AND UNIX)
set(LIB_ENV_VAR "DYLD_FALLBACK_LIBRARY_PATH=${SHIBOKEN_LIBRARY_PATH}:${LIBRARY_OUTPUT_PATH}")
if (ParaView_DIR)
set(VTKPY_DIR "${ParaView_DIR}/lib/site-packages:${ParaView_DIR}/lib:")
elseif (VTK_DIR)
set(VTKPY_DIR "${VTK_DIR}/lib/site-packages:${VTK_DIR}/lib:")
endif()
elseif(UNIX)
if (ParaView_DIR)
# Note that ending with a colon should only be done if followed by
# another path... be careful when changing LIB_ENV_VAR!
set(PV_LIB_DIR "${ParaView_DIR}/lib:")
set(VTKPY_DIR "${ParaView_DIR}/lib/site-packages:${PV_LIB_DIR}")
elseif (VTK_DIR)
set(PV_LIB_DIR "${VTK_DIR}/lib:")
set(VTKPY_DIR "${VTK_DIR}/lib/site-packages:${PV_LIB_DIR}")
endif()
set(LIB_ENV_VAR "LD_LIBRARY_PATH=${PV_LIB_DIR}${SHIBOKEN_LIBRARY_PATH}:${LIBRARY_OUTPUT_PATH}")
endif()
......@@ -242,7 +251,7 @@ if(SMTK_ENABLE_PYTHON_WRAPPING)
set(SHIBOKEN_SMTK_PYTHON "${SHIBOKEN_SMTK_PYTHON}${sep}${SHIBOKEN_PYTHONPATH}")
endif ()
endif()
#message("${LIB_ENV_VAR} PYTHONPATH=${SIBOKEN_SMTK_PYTHON}")
#message("${LIB_ENV_VAR} PYTHONPATH=${SHIBOKEN_SMTK_PYTHON}")
#message("${SHIBOKEN_LIBRARY_PATH}")
endif()
......
......@@ -15,7 +15,7 @@ if (SMTK_ENABLE_TESTING AND SMTK_ENABLE_PYTHON_WRAPPING AND SMTK_DATA_DIR AND SM
# Assign environment variables to the test(s)
set_tests_properties(tut-debug_python_test
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
ENVIRONMENT "PYTHONPATH=${VTKPY_DIR}${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endif()
......@@ -13,6 +13,6 @@ if (SMTK_ENABLE_TESTING AND SMTK_ENABLE_PYTHON_WRAPPING AND SMTK_DATA_DIR)
# Assign environment variables to the test(s)
set_tests_properties(tut-python_first_steps
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
ENVIRONMENT "PYTHONPATH=${VTKPY_DIR}${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endif()
......@@ -23,7 +23,7 @@ set_tests_properties(
attributeAutoNamingTestPy attributeAutoNamingTestPy
attributeReferencingTestPy categoryTestPy attributeFindItemTestPy
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
ENVIRONMENT "PYTHONPATH=${VTKPY_DIR}${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
if (SMTK_DATA_DIR AND EXISTS ${SMTK_DATA_DIR}/ReadMe.mkd)
......@@ -35,7 +35,7 @@ if (SMTK_DATA_DIR AND EXISTS ${SMTK_DATA_DIR}/ReadMe.mkd)
${SMTK_DATA_DIR})
set_tests_properties(${test}Py
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
ENVIRONMENT "PYTHONPATH=${VTKPY_DIR}${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
endif()
......@@ -14,7 +14,7 @@ foreach (test ${smtkCGMSessionPythonTests})
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}"
ENVIRONMENT "PYTHONPATH=${VTKPY_DIR}${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
......@@ -26,7 +26,7 @@ if (SMTK_DATA_DIR AND EXISTS ${SMTK_DATA_DIR}/ReadMe.mkd)
${SMTK_DATA_DIR})
set_tests_properties(${test}Py
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
ENVIRONMENT "PYTHONPATH=${VTKPY_DIR}${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
endif()
......@@ -74,6 +74,11 @@ class TestCGMBooleans(smtk.testing.TestCase):
self.assertImageMatchIfFileExists(['baselines', 'cgm', 'booleans.png'])
self.interact()
else:
self.assertFalse(
self.haveVTKExtension(),
'Could not import vtk. Python path is {pp}'.format(pp=sys.path))
mod = smtk.model.Model(bsuni)
self.assertEqual(
mod.geometryStyle(), smtk.model.PARAMETRIC,
......
......@@ -80,9 +80,14 @@ class CGMTransforms(smtk.testing.TestCase):
cam.SetViewUp(-0.891963, -0.122107, -0.435306)
self.renderer.ResetCamera()
self.renderWindow.Render()
self.assertImageMatch(['baselines', 'cgm', 'transforms.png'])
self.assertImageMatchIfFileExists(['baselines', 'cgm', 'transforms.png'])
self.interact()
else:
self.assertFalse(
self.haveVTKExtension(),
'Could not import vtk. Python path is {pp}'.format(pp=sys.path))
# Now verify that self.mgr.closeSession removes the entity record for the session.
sref = GetActiveSession()
SetActiveSession(smtk.model.SessionRef())
......
......@@ -11,7 +11,7 @@ foreach (test ${smtkDiscreteSessionPythonTests})
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}"
ENVIRONMENT "PYTHONPATH=${VTKPY_DIR}${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
......@@ -23,7 +23,7 @@ if (SMTK_DATA_DIR AND EXISTS ${SMTK_DATA_DIR}/ReadMe.mkd)
--data-dir=${SMTK_DATA_DIR})
set_tests_properties(${test}Py
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
ENVIRONMENT "PYTHONPATH=${VTKPY_DIR}${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
endif()
......@@ -90,8 +90,13 @@ class TestDiscreteSession(smtk.testing.TestCase):
self.assertImageMatch(['baselines', 'discrete', 'pmdc.png'])
self.interact()
else:
self.assertFalse(
self.haveVTKExtension(),
'Could not import vtk. Python path is {pp}'.format(pp=sys.path))
def setUp(self):
import os, sys
import os
self.resetTestFiles()
self.addTestFile(['cmb', 'test2D.cmb'], 4, 0, self.validateTest2D)
self.addTestFile(['cmb', 'SimpleBox.cmb'], 1, 2)
......
......@@ -11,7 +11,7 @@ foreach (test ${smtkExodusSessionPythonTests})
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}"
ENVIRONMENT "PYTHONPATH=${VTKPY_DIR}${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
......@@ -23,7 +23,7 @@ if (SMTK_DATA_DIR AND EXISTS ${SMTK_DATA_DIR}/ReadMe.mkd)
--data-dir=${SMTK_DATA_DIR})
set_tests_properties(${test}Py
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
ENVIRONMENT "PYTHONPATH=${VTKPY_DIR}${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
endif()
......@@ -12,11 +12,12 @@
import smtk
import smtk.testing
from smtk.simple import *
import sys
class TestExodusSession(smtk.testing.TestCase):
def setUp(self):
import os, sys
import os
self.filename = os.path.join(smtk.testing.DATA_DIR, 'exodus', 'disk_out_ref.ex2')
self.mgr = smtk.model.Manager.create()
......@@ -70,23 +71,28 @@ class TestExodusSession(smtk.testing.TestCase):
if self.haveVTK() and self.haveVTKExtension():
# Render groups with colors:
for grp in self.model.groups():
color = self.hex2rgb(nameset[grp.name()])
SetEntityProperty(grp, 'color', as_float=color)
# Render groups with colors:
for grp in self.model.groups():
color = self.hex2rgb(nameset[grp.name()])
SetEntityProperty(grp, 'color', as_float=color)
self.startRenderTest()
mbs = self.addModelToScene(self.model)
self.startRenderTest()
mbs = self.addModelToScene(self.model)
self.renderer.SetBackground(1,1,1)
cam = self.renderer.GetActiveCamera()
cam.SetFocalPoint(0., 0., 0.)
cam.SetPosition(19,17,-43)
cam.SetViewUp(-0.891963, -0.122107, -0.435306)
self.renderer.ResetCamera()
self.renderWindow.Render()
self.assertImageMatch(['baselines', 'exodus', 'disk_out_ref.png'])
self.interact()
self.renderer.SetBackground(1,1,1)
cam = self.renderer.GetActiveCamera()
cam.SetFocalPoint(0., 0., 0.)
cam.SetPosition(19,17,-43)
cam.SetViewUp(-0.891963, -0.122107, -0.435306)
self.renderer.ResetCamera()
self.renderWindow.Render()
self.assertImageMatch(['baselines', 'exodus', 'disk_out_ref.png'])
self.interact()
else:
self.assertFalse(
self.haveVTKExtension(),
'Could not import vtk. Python path is {pp}'.format(pp=sys.path))
if __name__ == '__main__':
smtk.testing.process_arguments()
......
......@@ -13,7 +13,7 @@ if (SMTK_DATA_DIR AND EXISTS "${SMTK_DATA_DIR}/ReadMe.mkd")
)
set_tests_properties(${test}Py
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
ENVIRONMENT "PYTHONPATH=${VTKPY_DIR}${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
endif()
......@@ -7,6 +7,6 @@ foreach (test ${smtkCommonPythonTests})
add_test(${test}Py ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${test}.py --src-dir=${SMTK_SOURCE_DIR})
set_tests_properties(${test}Py
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
ENVIRONMENT "PYTHONPATH=${VTKPY_DIR}${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
......@@ -16,7 +16,7 @@ if (SMTK_DATA_DIR AND EXISTS ${SMTK_DATA_DIR}/ReadMe.mkd)
--data-dir=${SMTK_DATA_DIR})
set_tests_properties(${test}Py
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
ENVIRONMENT "PYTHONPATH=${VTKPY_DIR}${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
endif()
......@@ -10,7 +10,7 @@ foreach (test ${smtkVTKExtPythonTests})
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}"
ENVIRONMENT "PYTHONPATH=${VTKPY_DIR}${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
......@@ -22,7 +22,7 @@ if (SMTK_DATA_DIR AND EXISTS ${SMTK_DATA_DIR}/ReadMe.mkd)
--data-dir=${SMTK_DATA_DIR})
set_tests_properties(${test}Py
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
ENVIRONMENT "PYTHONPATH=${VTKPY_DIR}${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
endif()
......@@ -23,7 +23,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}"
ENVIRONMENT "PYTHONPATH=${VTKPY_DIR}${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
......@@ -35,7 +35,7 @@ if (SMTK_DATA_DIR AND EXISTS ${SMTK_DATA_DIR}/ReadMe.mkd)
--data-dir=${SMTK_DATA_DIR})
set_tests_properties(${test}Py
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
ENVIRONMENT "PYTHONPATH=${VTKPY_DIR}${VTKPY_DIR}${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
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}"
ENVIRONMENT "PYTHONPATH=${VTKPY_DIR}${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