diff options
author | Brad King <brad.king@kitware.com> | 2018-04-12 15:27:23 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-04-12 15:28:31 (GMT) |
commit | b148d3ade0401525aa2f1896594957a79137c5a6 (patch) | |
tree | 6eea36bba6b0ff06a8c6e67e3cf48c3afef84ad6 | |
parent | f2376a5622e11279e2548aa515eff1ccca0d3bf0 (diff) | |
parent | ffb1f19191d96572a9fcae166e911a464a143a7a (diff) | |
download | CMake-b148d3ade0401525aa2f1896594957a79137c5a6.zip CMake-b148d3ade0401525aa2f1896594957a79137c5a6.tar.gz CMake-b148d3ade0401525aa2f1896594957a79137c5a6.tar.bz2 |
Merge topic 'FindMatlab-handle-exception'
ffb1f19191 FindMatlab: add unit tests
44c916b4c8 FindMatlab: always handle uncaught exception
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1946
-rw-r--r-- | Modules/MatlabTestsRedirect.cmake | 5 | ||||
-rw-r--r-- | Tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/FindMatlab/basic_checks/CMakeLists.txt | 7 | ||||
-rw-r--r-- | Tests/FindMatlab/failure_reports/CMakeLists.txt | 39 |
4 files changed, 47 insertions, 5 deletions
diff --git a/Modules/MatlabTestsRedirect.cmake b/Modules/MatlabTestsRedirect.cmake index 64d580d..fc36fc3 100644 --- a/Modules/MatlabTestsRedirect.cmake +++ b/Modules/MatlabTestsRedirect.cmake @@ -55,11 +55,12 @@ endif() if(no_unittest_framework) - set(unittest_to_run "try, ${unittest_file_to_run_name}, catch err, disp('An exception has been thrown during the execution'), disp(err), disp(err.stack), exit(1), end, exit(0)") + set(unittest_to_run "${unittest_file_to_run_name}") endif() +set(command_to_run "try, ${unittest_to_run}, catch err, disp('An exception has been thrown during the execution'), disp(err), disp(err.stack), exit(1), end, exit(0)") set(Matlab_SCRIPT_TO_RUN - "addpath(${concat_string}); ${cmd_to_run_before_test}; ${unittest_to_run}" + "addpath(${concat_string}); ${cmd_to_run_before_test}; ${command_to_run}" ) # if the working directory is not specified then default # to the output_directory because the log file will go there diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 1309c42..aad7cfc 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1442,6 +1442,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ADD_TEST_MACRO(FindMatlab.basic_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) ADD_TEST_MACRO(FindMatlab.versions_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) ADD_TEST_MACRO(FindMatlab.components_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) + ADD_TEST_MACRO(FindMatlab.failure_reports ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) endif() find_package(GTK2 QUIET) diff --git a/Tests/FindMatlab/basic_checks/CMakeLists.txt b/Tests/FindMatlab/basic_checks/CMakeLists.txt index bf54427..951fcf2 100644 --- a/Tests/FindMatlab/basic_checks/CMakeLists.txt +++ b/Tests/FindMatlab/basic_checks/CMakeLists.txt @@ -24,11 +24,12 @@ matlab_add_mex( matlab_add_unit_test( NAME ${PROJECT_NAME}_matlabtest-1 - TIMEOUT 90 + TIMEOUT 300 UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests1.m ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1> ) +# timeout tests, TIMEOUT set to very short on purpose matlab_add_unit_test( NAME ${PROJECT_NAME}_matlabtest-2 TIMEOUT 15 @@ -41,7 +42,7 @@ set_tests_properties(${PROJECT_NAME}_matlabtest-2 PROPERTIES WILL_FAIL TRUE) # testing the test without the unittest framework of Matlab matlab_add_unit_test( NAME ${PROJECT_NAME}_matlabtest-3 - TIMEOUT 30 + TIMEOUT 300 NO_UNITTEST_FRAMEWORK UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests2.m ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1> @@ -49,7 +50,7 @@ matlab_add_unit_test( matlab_add_unit_test( NAME ${PROJECT_NAME}_matlabtest-4 - TIMEOUT 30 + TIMEOUT 300 NO_UNITTEST_FRAMEWORK UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests3.m ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1> diff --git a/Tests/FindMatlab/failure_reports/CMakeLists.txt b/Tests/FindMatlab/failure_reports/CMakeLists.txt new file mode 100644 index 0000000..1cf9613 --- /dev/null +++ b/Tests/FindMatlab/failure_reports/CMakeLists.txt @@ -0,0 +1,39 @@ + +cmake_minimum_required (VERSION 2.8.12) +enable_testing() +project(failure_reports) + +# gather tests about proper failure reports + +set(MATLAB_FIND_DEBUG TRUE) + +find_package(Matlab REQUIRED COMPONENTS MX_LIBRARY MAIN_PROGRAM) + +# main extensions for testing, same as other tests +matlab_add_mex( + # target name + NAME cmake_matlab_test_wrapper1 + # output name + OUTPUT_NAME cmake_matlab_mex1 + SRC ${CMAKE_CURRENT_SOURCE_DIR}/../matlab_wrapper1.cpp + DOCUMENTATION ${CMAKE_CURRENT_SOURCE_DIR}/../help_text1.m.txt + ) + +# the unit test file does not exist: the failure should be properly reported +matlab_add_unit_test( + NAME ${PROJECT_NAME}_matlabtest-1 + TIMEOUT 300 + UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../nonexistantfile.m + ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1> + ) +set_tests_properties(${PROJECT_NAME}_matlabtest-1 PROPERTIES WILL_FAIL TRUE) + +# without the unit test framework +matlab_add_unit_test( + NAME ${PROJECT_NAME}_matlabtest-2 + TIMEOUT 300 + NO_UNITTEST_FRAMEWORK + UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../nonexistantfile2.m + ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1> + ) +set_tests_properties(${PROJECT_NAME}_matlabtest-2 PROPERTIES WILL_FAIL TRUE) |