testing.cmake 2.72 KB
Newer Older
1
#
Julien Michel's avatar
Julien Michel committed
2
# Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#
# This file is part of Orfeo Toolbox
#
#     https://www.orfeo-toolbox.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
20 21 22 23 24
# add_test(NAME <name> COMMAND <command> [<arg>...]
#          [CONFIGURATIONS <config>...]
#          [WORKING_DIRECTORY <dir>])

set(testing_dir ${CMAKE_BINARY_DIR}/tests)
25 26 27 28 29 30
if(EXISTS "${testing_dir}")
  execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ${testing_dir})
  execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory   ${testing_dir})
else()
  execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory   ${testing_dir})
endif()
31

32 33
set(install_package_ARGS)
set(selftester_ARGS)
34 35
set(pkg_extracted_dir "${testing_dir}/${PKG_STAGE_DIR}")
if(WIN32)
36 37 38 39 40
  set(install_package_ARGS "x;${PACKAGE_OUTPUT_FILE}")
  set(install_package_CMD "${ZIP_EXECUTABLE}")
  #selftester
  set(selftester_CMD ${pkg_extracted_dir}/tools/selftester.bat)
  set(selftester_ARGS "/q")
41 42
  #uninstall OTB
  set(uninstall_otb_CMD ${pkg_extracted_dir}/tools/uninstall_otb.bat)
43
else()
44
  set(install_package_ARGS "--noprogress;--nox11;--target;${pkg_extracted_dir}")
45 46 47 48
  set(install_package_CMD "${PACKAGE_OUTPUT_FILE}")
  #selftester
  set(selftester_CMD ${pkg_extracted_dir}/tools/selftester.sh)
  set(selftester_ARGS)
49 50
  #uninstall OTB
  set(uninstall_otb_CMD ${pkg_extracted_dir}/tools/uninstall_otb.sh)
51
endif()
52 53
add_test(
  NAME Tu_install_package
54
  COMMAND ${install_package_CMD} ${install_package_ARGS}
55 56 57
  WORKING_DIRECTORY ${testing_dir}
  )

58 59
add_test(
  NAME Tu_selftester
60
  COMMAND ${selftester_CMD} ${selftester_ARGS}
61
  WORKING_DIRECTORY ${pkg_extracted_dir}
62 63
  )

64
add_test(
65
  NAME Tu_build_examples
66 67
  COMMAND ${CMAKE_COMMAND}
  -DSRC_DIR=${CMAKE_SOURCE_DIR}/../Examples
68
  -P ${pkg_extracted_dir}/tools/build_examples.cmake
69 70
  WORKING_DIRECTORY ${testing_dir}
  )
Rashad Kanavath's avatar
Rashad Kanavath committed
71 72

add_test(
73
  NAME Tu_uninstall_otb
74
  COMMAND ${uninstall_otb_CMD}
Rashad Kanavath's avatar
Rashad Kanavath committed
75 76
  WORKING_DIRECTORY ${testing_dir}
  )
77

78 79
#configure test dependencies..
set_tests_properties ( Tu_selftester PROPERTIES DEPENDS Tu_install_package)
80 81
set_tests_properties ( Tu_build_examples PROPERTIES DEPENDS Tu_selftester)
set_tests_properties ( Tu_uninstall_otb PROPERTIES DEPENDS Tu_build_examples)
82 83 84 85

#if(UNIX)
  #TODO: add test with shellcheck for script files
#endif()