Commit 7e75d755 authored by John Tourtellott's avatar John Tourtellott Committed by Kitware Robot
Browse files

Merge topic 'package-python-test'

5865f15e Fix paths to config files in apple package
6ccb6410 Replace os-specific shell scripts with cmake script
610bd74b Add powershell script for windows package tests
de44cf98 Add extract dependency to import test
16f1e758 Updates for macOS test; moves modelbuilder.app to root folder
ec8ad4da

 Add tests to extract modelbuilder package and check python import
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Ben Boeckel's avatarBen Boeckel <ben.boeckel@kitware.com>
Merge-request: !665
parents ecfdbb6c 5865f15e
Pipeline #211190 failed with stages
......@@ -26,6 +26,7 @@ if ("$ENV{CI_JOB_NAME}" MATCHES "centos7")
"UnitTestRead(2dm|3dm|Obj|Pts|Stl|Vtp|Xyz)"
"DeleteSmtkCell"
"discreteImport2dmTest"
"^package-import-test"
"^pv\\."
"RenderMesh"
"unitQtComponentItem")
......
......@@ -274,6 +274,7 @@ function (superbuild_add_packaging)
if (cmb_enabled)
include(cmb.suffix)
include(package.test)
list(APPEND superbuild_export_variables
CMB_PACKAGE_SUFFIX)
......@@ -286,6 +287,16 @@ function (superbuild_add_packaging)
superbuild_add_extra_package_test(modelbuilder "${generator}"
LABELS "CMB"
TIMEOUT 6400)
add_package_extract_test("${generator}"
DEPENDS "cpack-modelbuilder-${generator}"
LABELS "CMB"
)
add_package_import_test("${generator}"
DEPENDS "extract-modelbuilder-${generator}"
LABELS "CMB"
)
endforeach ()
endif ()
......
# Script for running modelbuilder test script, expected it to generate
# a file as a result.
# Requred variables:
# EXECUTABLE: path to the modelbuilder executable
# EXPECTED_FILE: path to the file that modelbuilder generates
# DATA_DIR: argument to pass to --data-directory
# TEST_DIR: argument to pass to --test-directory
# TEST_SCRIPT: path to the test (.xml) file to play
# Remove expected file before running modelbuilder
if (EXISTS ${EXPECTED_FILE})
file(REMOVE ${EXPECTED_FILE})
endif ()
# Run modelbuilder
execute_process(
COMMAND
${EXECUTABLE}
"-dr"
"--data-directory=${DATA_DIR}"
"--test-directory=${TEST_DIR}"
"--test-script=${TEST_SCRIPT}"
"--exit"
RESULT_VARIABLE error_code
)
if (error_code)
message(FATAL_ERROR "Modelbuilder returned error code ${error_code}.")
endif ()
# Check if expected file was generated
if (NOT EXISTS ${EXPECTED_FILE})
message(FATAL_ERROR "The expected file (${EXPECTED_FILE}) was not generated.")
endif ()
include (SuperbuildTestingMacros)
set(modelbuilder_extract_root "${CMAKE_BINARY_DIR}/Testing/Temporary")
if (CMB_PACKAGE_FILE_NAME)
set(glob_prefix "${CMB_PACKAGE_FILE_NAME}")
else ()
set(glob_prefix "modelbuilder-*")
if (CMB_PACKAGE_SUFFIX)
set(glob_prefix "${glob_prefix}-${CMB_PACKAGE_SUFFIX}")
endif ()
endif ()
#[==[.md
Test that extracts modelbuilder package file
```
add_package_extract_test(generator)
```
This test calls the superbuild_add_extract_test to extract the modelbuilder
package file.
#]==]
function (add_package_extract_test generator)
set(extract_dir "${modelbuilder_extract_root}/modelbuilder-${generator}/test-extracted")
superbuild_add_extract_test("modelbuilder" "${glob_prefix}" "${generator}" "${extract_dir}")
endfunction ()
#[==[.md
Tests that extracted modelbuilder executable can import smtk python modules.
```
add_package_import_test(generator)
```
This test runs modelbuilder and checks if it can import a minimal smtk operation,
which requires the python environment to be configured correctly.
* The test command runs a cmake script that runs the modelbuilder executable.
* Variables passed to the cmake script specify the paths to the executable,
the xml script, and other needed info.
* The xml script invokes the modelbuilder "Import Python Operation..." menu
item and selects a python file "minimum_operation.py" in the scripts
subfolder).
* If the import operation is successful, a small text file is generated in
the test directory.
#]==]
function (add_package_import_test generator)
set(extract_dir "${modelbuilder_extract_root}/modelbuilder-${generator}/test-extracted")
set(this_dir "${CMAKE_SOURCE_DIR}/cmake")
set(test_dir "${CMAKE_BINARY_DIR}/Testing/Temporary")
set(exe_path "bin/modelbuilder")
if (APPLE)
set(exe_path "modelbuilder.app/Contents/MacOS/modelbuilder")
endif ()
add_test(
NAME "package-import-test-${generator}"
COMMAND
"${CMAKE_COMMAND}"
"-DEXECUTABLE=${extract_dir}/${exe_path}"
"-DEXPECTED_FILE=${test_dir}/minimum_operation.txt"
"-DDATA_DIR=${this_dir}/scripts"
"-DTEST_DIR=${test_dir}"
"-DTEST_SCRIPT=${this_dir}/scripts/import_minimum_operation.xml"
"-P" "${this_dir}/import_pythonop.cmake"
WORKING_DIRECTORY "${test_dir}"
)
set_tests_properties("package-import-test-${generator}"
PROPERTIES
${ARGN}
)
endfunction ()
<?xml version="1.0" ?>
<pqevents>
<pqevent object="pqClientMainWindow/menubar" command="activate" arguments="menu_File" />
<pqevent object="pqClientMainWindow/menubar/menu_File" command="activate" arguments="&amp;Import Operation..." />
<pqevent object="pqClientMainWindow/OperationImportDialog" command="filesSelected" arguments="$PARAVIEW_DATA_ROOT/minimum_operation.py" />
</pqevents>
"""A minimum pythonn operation to verify that smtk python modules
can be imported and operations loaded.
"""
import os
import smtk
import smtk.attribute
import smtk.common
import smtk.io
import smtk.mesh
import smtk.model
import smtk.operation
import smtk.resource
import smtk.simulation
import smtk.view
class MinimumOperation(smtk.operation.Operation):
def __init__(self):
smtk.operation.Operation.__init__(self)
def name(self):
return "Minimal Operation"
def operateInternal(self):
outcome = int(smtk.operation.Operation.Outcome.SUCCEEDED)
result = self.createResult(outcome)
return result
def createSpecification(self):
spec = self.createBaseSpecification()
return spec
# Write small text file, which is used to confirm that import was successful.
wd = os.getcwd()
filename = 'minimum_operation.txt'
path = os.path.join(wd, filename)
with open(path, 'w') as f2:
f2.write(filename)
print('Wrote', path)
......@@ -41,7 +41,7 @@ foreach(program IN LISTS cmb_programs_to_install)
endif ()
superbuild_apple_create_app(
"\${CMAKE_INSTALL_PREFIX}/${cmb_package}"
"\${CMAKE_INSTALL_PREFIX}"
"${program}.app"
"${superbuild_install_location}/Applications/${program}.app/Contents/MacOS/${program}"
CLEAN
......@@ -54,18 +54,18 @@ foreach(program IN LISTS cmb_programs_to_install)
if (EXISTS "${icon_path}")
install(
FILES "${icon_path}"
DESTINATION "${cmb_package}/${program}.app/Contents/Resources"
DESTINATION "${program}.app/Contents/Resources"
COMPONENT superbuild)
endif ()
endforeach ()
install(
FILES "${superbuild_install_location}/Applications/${program}.app/Contents/Info.plist"
DESTINATION "${cmb_package}/${program}.app/Contents"
DESTINATION "${program}.app/Contents"
COMPONENT superbuild)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/${program}.conf"
DESTINATION "${cmb_package}/${program}.app/Contents/Resources/"
DESTINATION "${program}.app/Contents/Resources/"
COMPONENT superbuild)
foreach (app_plugin_file IN LISTS app_plugin_files)
if (NOT app_plugin_file)
......@@ -78,13 +78,13 @@ foreach(program IN LISTS cmb_programs_to_install)
endif ()
install(
FILES "${plugin_source_path}"
DESTINATION "${cmb_package}/${program}.app/Contents/Plugins/"
DESTINATION "${program}.app/Contents/Plugins/"
COMPONENT superbuild)
endforeach ()
foreach (executable IN LISTS paraview_executables)
superbuild_apple_install_utility(
"\${CMAKE_INSTALL_PREFIX}/${cmb_package}"
"\${CMAKE_INSTALL_PREFIX}"
"${program}.app"
"${superbuild_install_location}/bin/${executable}"
SEARCH_DIRECTORIES
......@@ -92,21 +92,20 @@ foreach(program IN LISTS cmb_programs_to_install)
endforeach ()
install(CODE
"file(MAKE_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/${cmb_package}/${program}.app/Contents/Resources\")
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${cmb_package}/${program}.app/Contents/Resources/qt.conf\" \"[Paths]\nPlugins = Plugins\n\")"
"file(MAKE_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/${program}.app/Contents/Resources\")
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${program}.app/Contents/Resources/qt.conf\" \"[Paths]\nPlugins = Plugins\n\")"
COMPONENT superbuild)
if (python3_built_by_superbuild)
include(python3.functions)
superbuild_install_superbuild_python3(
DESTINATION_SUBDIR "${cmb_package}"
BUNDLE "${program}.app")
endif ()
file(GLOB egg_dirs
"${superbuild_install_location}/lib/python${superbuild_python_version}/site-packages/*.egg/")
superbuild_apple_install_python(
"\${CMAKE_INSTALL_PREFIX}/${cmb_package}"
"\${CMAKE_INSTALL_PREFIX}"
"${program}.app"
MODULES ${cmb_python_modules}
MODULE_DIRECTORIES
......@@ -120,25 +119,25 @@ foreach(program IN LISTS cmb_programs_to_install)
if (matplotlib_enabled)
install(
DIRECTORY "${superbuild_install_location}/lib/python${superbuild_python_version}/site-packages/matplotlib/mpl-data/"
DESTINATION "${cmb_package}/${program}.app/Contents/Python/matplotlib/mpl-data"
DESTINATION "${program}.app/Contents/Python/matplotlib/mpl-data"
COMPONENT superbuild)
endif ()
if (pythonrequests_enabled)
install(
FILES "${superbuild_install_location}/lib/python${superbuild_python_version}/site-packages/requests/cacert.pem"
DESTINATION "${cmb_package}/${program}.app/Contents/Python/requests"
DESTINATION "${program}.app/Contents/Python/requests"
COMPONENT superbuild)
endif ()
if (paraviewweb_enabled)
install(
FILES "${superbuild_install_location}/Applications/paraview.app/Contents/Python/paraview/web/defaultProxies.json"
DESTINATION "${cmb_package}/${program}.app/Contents/Python/paraview/web"
DESTINATION "${program}.app/Contents/Python/paraview/web"
COMPONENT "superbuild")
install(
DIRECTORY "${superbuild_install_location}/share/paraview/web"
DESTINATION "${cmb_package}/${program}.app/Contents/Resources"
DESTINATION "${program}.app/Contents/Resources"
COMPONENT "superbuild")
endif ()
......@@ -147,7 +146,7 @@ foreach(program IN LISTS cmb_programs_to_install)
get_filename_component(qt5_plugin_group "${qt5_plugin_group}" NAME)
superbuild_apple_install_module(
"\${CMAKE_INSTALL_PREFIX}/${cmb_package}"
"\${CMAKE_INSTALL_PREFIX}"
"${program}.app"
"${qt5_plugin_path}"
"Contents/Plugins/${qt5_plugin_group}"
......@@ -155,7 +154,7 @@ foreach(program IN LISTS cmb_programs_to_install)
endforeach ()
if (cmb_doc_base_dir)
set(cmb_doc_dir "${cmb_package}/${program}.app/${cmb_doc_base_dir}")
set(cmb_doc_dir "${program}.app/${cmb_doc_base_dir}")
endif ()
# Install PDF guides.
......@@ -173,7 +172,7 @@ endif ()
if (meshkit_enabled)
foreach (meshkit_exe IN ITEMS coregen assygen)
superbuild_apple_install_utility(
"\${CMAKE_INSTALL_PREFIX}/${cmb_package}"
"\${CMAKE_INSTALL_PREFIX}"
"modelbuilder.app"
"${superbuild_install_location}/bin/${meshkit_exe}"
SEARCH_DIRECTORIES "${library_paths}"
......
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