Debian Codegraph @

sdk/applications/config/CMakeLists.txt

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 camitk_application(NO_GUI
2 ADDITIONAL_SOURCES CommandLineOptions.cxx CommandLineOptions.hxx
3 CEP_NAME SDK
4 DESCRIPTION "Provides information about your CamiTK configuration and installation"
5 )
6
7 if(NOT APPLICATION_CONFIG)
8 message(FATAL_ERROR "APPLICATION_CONFIG cannot be set to OFF, it is mandatory for any CamiTK installation")
9 else()
10 # get more revision information
11 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CamiTKVersionInformation.h.in ${CMAKE_CURRENT_BINARY_DIR}/CamiTKVersionInformation.h @ONLY)
12 endif()
13
14 set(TEST_BASENAME ${APPLICATION_TARGET_NAME})
15 camitk_init_test(${TEST_BASENAME})
16
17 # should pass because invoking config without arguments or with help arg shows usage and exit success
18 camitk_add_test(PROJECT_NAME ${TEST_BASENAME} TEST_SUFFIX "-")
19
20 camitk_add_test(EXECUTABLE_ARGS "--help" PROJECT_NAME ${TEST_BASENAME} TEST_SUFFIX "-")
21
22 camitk_add_test(EXECUTABLE_ARGS "-h" PROJECT_NAME ${TEST_BASENAME} TEST_SUFFIX "-")
23
24 # test #4
25 # should pass because invoking camitk-config with a faulty arguments results in printing
26 # an error message (and exit failure)
27 camitk_add_test(EXECUTABLE_ARGS "-badarg"
28 PASS_REGULAR_EXPRESSION "unknown option '-badarg'"
29 PROJECT_NAME ${TEST_BASENAME} TEST_SUFFIX "-")
30
31 camitk_add_test(EXECUTABLE_ARGS "-e"
32 PASS_REGULAR_EXPRESSION "missing value for option '-e'"
33 PROJECT_NAME ${TEST_BASENAME} TEST_SUFFIX "-")
34
35 camitk_add_test(EXECUTABLE_ARGS "-e badfile"
36 PASS_REGULAR_EXPRESSION "Error opening .camitk JSON file badfile"
37 PROJECT_NAME ${TEST_BASENAME} TEST_SUFFIX "-")
38
39 if(PYTHON_BINDING)
40 # Test missing python script.
41 # The following test must fails as the python scripts are not available in the directory
42 # Copy a known camitk extension file
43 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/testing)
44 set(CAMITK_EXTENSION_FILE_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/../../libraries/extensiongenerator/testing/resources/multiActionsPython.camitk)
45 set(CAMITK_EXTENSION_FILE_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/testing/multiActionsPython.camitk)
46 # Add a custom command to copy the test file at build time
47 add_custom_command(
48 TARGET ${APPLICATION_TARGET_NAME} POST_BUILD
49 COMMAND ${CMAKE_COMMAND} -E copy
50 ${CAMITK_EXTENSION_FILE_SOURCE}
51 ${CAMITK_EXTENSION_FILE_DESTINATION}
52 COMMENT "Copying camitk extension file to test for config test..."
53 )
54 camitk_add_test(EXECUTABLE_ARGS "-e ${CAMITK_EXTENSION_FILE_DESTINATION}"
55 # as no .py scripts where copied alongside the .camitk, python hotplug extension should fail
56 PASS_REGULAR_EXPRESSION "sdk/applications/config/testing/do_something_on_meshcomponent.py' not found"
57 PROJECT_NAME ${TEST_BASENAME} TEST_SUFFIX "-")
58 endif()
59
60 # Add config test
61 find_program (BASH_PROGRAM bash)
62 if(BASH_PROGRAM)
63 add_test(NAME ${APPLICATION_TARGET_NAME}-bash-test
64 COMMAND ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/testing/config-test.sh -inbuild ${PROJECT_BINARY_DIR}
65 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} # needs to be at the top of the CamiTK module repository
66 )
67 # add test to this subproject (can be tested in local build dir using "ctest -L application-config")
68 set_tests_properties(${APPLICATION_TARGET_NAME}-bash-test PROPERTIES LABELS "${APPLICATION_TARGET_NAME}")
69 endif(BASH_PROGRAM)