[Cmake-commits] CMake branch, next, updated. v3.6.2-1922-gf8fc47d

Bill Hoffman bill.hoffman at kitware.com
Fri Sep 9 16:53:45 EDT 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  f8fc47db59a6cbd16a4fdd3238e82f8a5561631f (commit)
       via  e42471b9d4e4e99f38200a87121f46a7991510cd (commit)
       via  9e8dc649129b8ec711d6fb854d4f9576c0dd4dc9 (commit)
       via  7d2e9dd88c154707c7434c27edb34de948a51d60 (commit)
      from  e0aa392d59fed43a0de907fc31518adc8ca1d74e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f8fc47db59a6cbd16a4fdd3238e82f8a5561631f
commit f8fc47db59a6cbd16a4fdd3238e82f8a5561631f
Merge: e0aa392 e42471b
Author:     Bill Hoffman <bill.hoffman at kitware.com>
AuthorDate: Fri Sep 9 16:53:44 2016 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Fri Sep 9 16:53:44 2016 -0400

    Merge topic 'extend_matlab_unit_test' into next
    
    e42471b9 remove stray }
    9e8dc649 use single value args
    7d2e9dd8 Extend matlab_add_unit_test to run arbitrary code for the test.


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e42471b9d4e4e99f38200a87121f46a7991510cd
commit e42471b9d4e4e99f38200a87121f46a7991510cd
Author:     Bill Hoffman <bill.hoffman at kitware.com>
AuthorDate: Fri Sep 9 16:33:36 2016 -0400
Commit:     Bill Hoffman <bill.hoffman at kitware.com>
CommitDate: Fri Sep 9 16:33:36 2016 -0400

    remove stray }

diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index fd222fd..0462bd0 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -788,7 +788,7 @@ function(matlab_add_unit_test)
   add_test(NAME ${${prefix}_NAME}
            COMMAND ${CMAKE_COMMAND}
             "-Dtest_name=${${prefix}_NAME}"
-            "-Dadditional_paths=${${prefix}_ADDITIONAL_PATH}}"
+            "-Dadditional_paths=${${prefix}_ADDITIONAL_PATH}"
             "-Dtest_timeout=${${prefix}_TIMEOUT}"
             "-Doutput_directory=${_matlab_temporary_folder}"
             "-Dworking_directory=${${prefix}_WORKING_DIRECTORY}"
@@ -796,7 +796,7 @@ function(matlab_add_unit_test)
             "-Dno_unittest_framework=${${prefix}_NO_UNITTEST_FRAMEWORK}"
             "-DMatlab_ADDITIONNAL_STARTUP_OPTIONS=${${prefix}_MATLAB_ADDITIONAL_STARTUP_OPTIONS}"
             "-Dunittest_file_to_run=${${prefix}_UNITTEST_FILE}"
-            "-Dcustom_Matlab_test_command=${${prefix}_CUSTOM_TEST_COMMAND}}"
+            "-Dcustom_Matlab_test_command=${${prefix}_CUSTOM_TEST_COMMAND}"
             "-Dcmd_to_run_before_test=${${prefix}_UNITTEST_PRECOMMAND}"
             -P ${_FindMatlab_SELF_DIR}/MatlabTestsRedirect.cmake
            ${${prefix}_TEST_ARGS}

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9e8dc649129b8ec711d6fb854d4f9576c0dd4dc9
commit 9e8dc649129b8ec711d6fb854d4f9576c0dd4dc9
Author:     Bill Hoffman <bill.hoffman at kitware.com>
AuthorDate: Fri Sep 9 14:44:48 2016 -0400
Commit:     Bill Hoffman <bill.hoffman at kitware.com>
CommitDate: Fri Sep 9 14:44:48 2016 -0400

    use single value args

diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index 7c03635..fd222fd 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -773,9 +773,10 @@ function(matlab_add_unit_test)
   endif()
 
   set(options NO_UNITTEST_FRAMEWORK)
-  set(oneValueArgs NAME UNITTEST_FILE TIMEOUT WORKING_DIRECTORY)
-  set(multiValueArgs UNITTEST_PRECOMMAND ADDITIONAL_PATH
-    MATLAB_ADDITIONAL_STARTUP_OPTIONS TEST_ARGS CUSTOM_TEST_COMMAND)
+  set(oneValueArgs NAME UNITTEST_FILE TIMEOUT WORKING_DIRECTORY
+    UNITTEST_PRECOMMAND CUSTOM_TEST_COMMAND)
+  set(multiValueArgs ADDITIONAL_PATH MATLAB_ADDITIONAL_STARTUP_OPTIONS
+    TEST_ARGS)
 
   set(prefix _matlab_unittest_prefix)
   cmake_parse_arguments(PARSE_ARGV 0 ${prefix} "${options}" "${oneValueArgs}" "${multiValueArgs}" )

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7d2e9dd88c154707c7434c27edb34de948a51d60
commit 7d2e9dd88c154707c7434c27edb34de948a51d60
Author:     Bill Hoffman <bill.hoffman at kitware.com>
AuthorDate: Tue Aug 30 15:02:35 2016 -0400
Commit:     Bill Hoffman <bill.hoffman at kitware.com>
CommitDate: Fri Sep 9 14:41:53 2016 -0400

    Extend matlab_add_unit_test to run arbitrary code for the test.
    
    This commit allows a custom matlab set of commands to be run
    as the test instead of runtests('matlab_file_name'). It also
    escapes strings for matlab commands to allow for complicated
    matlab commands to be passed into the tests.

diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index b501599..7c03635 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -635,7 +635,7 @@ function(matlab_get_version_from_matlab_run matlab_binary_program matlab_list_ve
     set(devnull INPUT_FILE NUL)
   endif()
 
-  # timeout set to 30 seconds, in case it does not start
+  # timeout set to 120 seconds, in case it does not start
   # note as said before OUTPUT_VARIABLE cannot be used in a platform
   # independent manner however, not setting it would flush the output of Matlab
   # in the current console (unix variant)
@@ -644,12 +644,17 @@ function(matlab_get_version_from_matlab_run matlab_binary_program matlab_list_ve
     OUTPUT_VARIABLE _matlab_version_from_cmd_dummy
     RESULT_VARIABLE _matlab_result_version_call
     ERROR_VARIABLE _matlab_result_version_call_error
-    TIMEOUT 30
+    TIMEOUT 120
     WORKING_DIRECTORY "${_matlab_temporary_folder}"
     ${devnull}
     )
-
-
+  if("${_matlab_result_version_call}" MATCHES "timeout")
+    if(MATLAB_FIND_DEBUG)
+      message(WARNING "[MATLAB] Unable to determine the version of Matlab."
+        " Matlab call timed out after 120 seconds.")
+    endif()
+    return()
+  endif()
   if(${_matlab_result_version_call})
     if(MATLAB_FIND_DEBUG)
       message(WARNING "[MATLAB] Unable to determine the version of Matlab. Matlab call returned with error ${_matlab_result_version_call}.")
@@ -698,7 +703,6 @@ function(matlab_get_version_from_matlab_run matlab_binary_program matlab_list_ve
 
 endfunction()
 
-
 #.rst:
 # .. command:: matlab_add_unit_test
 #
@@ -720,6 +724,7 @@ endfunction()
 #     matlab_add_unit_test(
 #         NAME <name>
 #         UNITTEST_FILE matlab_file_containing_unittest.m
+#         [CUSTOM_MATLAB_COMMAND matlab_command_to_run_as_test]
 #         [UNITTEST_PRECOMMAND matlab_command_to_run]
 #         [TIMEOUT timeout]
 #         [ADDITIONAL_PATH path1 [path2 ...]]
@@ -735,6 +740,11 @@ endfunction()
 #   ``UNITTEST_FILE``
 #     the matlab unittest file. Its path will be automatically
 #     added to the Matlab path.
+#   ``CUSTOM_MATLAB_COMMAND``
+#     Matlab script command to run as the test.
+#     IIf this is not set, then the following is run:
+#     "runtests('matlab_file_name'), exit(max([ans(1,:).Failed]))
+#     matlab_file_name comes from UNITTEST_FILE without the .m.
 #   ``UNITTEST_PRECOMMAND``
 #     Matlab script command to be ran before the file
 #     containing the test (eg. GPU device initialisation based on CMake
@@ -748,6 +758,7 @@ endfunction()
 #   ``MATLAB_ADDITIONAL_STARTUP_OPTIONS``
 #     a list of additional option in order
 #     to run Matlab from the command line.
+#     -nosplash -nodesktop -nodisplay are always added.
 #   ``TEST_ARGS``
 #     Additional options provided to the add_test command. These
 #     options are added to the default options (eg. "CONFIGURATIONS Release")
@@ -762,11 +773,12 @@ function(matlab_add_unit_test)
   endif()
 
   set(options NO_UNITTEST_FRAMEWORK)
-  set(oneValueArgs NAME UNITTEST_PRECOMMAND UNITTEST_FILE TIMEOUT)
-  set(multiValueArgs ADDITIONAL_PATH MATLAB_ADDITIONAL_STARTUP_OPTIONS TEST_ARGS)
+  set(oneValueArgs NAME UNITTEST_FILE TIMEOUT WORKING_DIRECTORY)
+  set(multiValueArgs UNITTEST_PRECOMMAND ADDITIONAL_PATH
+    MATLAB_ADDITIONAL_STARTUP_OPTIONS TEST_ARGS CUSTOM_TEST_COMMAND)
 
   set(prefix _matlab_unittest_prefix)
-  cmake_parse_arguments(${prefix} "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
+  cmake_parse_arguments(PARSE_ARGV 0 ${prefix} "${options}" "${oneValueArgs}" "${multiValueArgs}" )
 
   if(NOT ${prefix}_NAME)
     message(FATAL_ERROR "[MATLAB] The Matlab test name cannot be empty")
@@ -774,15 +786,17 @@ function(matlab_add_unit_test)
 
   add_test(NAME ${${prefix}_NAME}
            COMMAND ${CMAKE_COMMAND}
-            -Dtest_name=${${prefix}_NAME}
-            -Dadditional_paths=${${prefix}_ADDITIONAL_PATH}
-            -Dtest_timeout=${${prefix}_TIMEOUT}
-            -Doutput_directory=${_matlab_temporary_folder}
-            -DMatlab_PROGRAM=${Matlab_MAIN_PROGRAM}
-            -Dno_unittest_framework=${${prefix}_NO_UNITTEST_FRAMEWORK}
-            -DMatlab_ADDITIONNAL_STARTUP_OPTIONS=${${prefix}_MATLAB_ADDITIONAL_STARTUP_OPTIONS}
-            -Dunittest_file_to_run=${${prefix}_UNITTEST_FILE}
-            -Dcmd_to_run_before_test=${${prefix}_UNITTEST_PRECOMMAND}
+            "-Dtest_name=${${prefix}_NAME}"
+            "-Dadditional_paths=${${prefix}_ADDITIONAL_PATH}}"
+            "-Dtest_timeout=${${prefix}_TIMEOUT}"
+            "-Doutput_directory=${_matlab_temporary_folder}"
+            "-Dworking_directory=${${prefix}_WORKING_DIRECTORY}"
+            "-DMatlab_PROGRAM=${Matlab_MAIN_PROGRAM}"
+            "-Dno_unittest_framework=${${prefix}_NO_UNITTEST_FRAMEWORK}"
+            "-DMatlab_ADDITIONNAL_STARTUP_OPTIONS=${${prefix}_MATLAB_ADDITIONAL_STARTUP_OPTIONS}"
+            "-Dunittest_file_to_run=${${prefix}_UNITTEST_FILE}"
+            "-Dcustom_Matlab_test_command=${${prefix}_CUSTOM_TEST_COMMAND}}"
+            "-Dcmd_to_run_before_test=${${prefix}_UNITTEST_PRECOMMAND}"
             -P ${_FindMatlab_SELF_DIR}/MatlabTestsRedirect.cmake
            ${${prefix}_TEST_ARGS}
            ${${prefix}_UNPARSED_ARGUMENTS}
@@ -1034,7 +1048,7 @@ function(_Matlab_get_version_from_root matlab_root matlab_known_version matlab_f
   if(${list_of_all_versions_length} GREATER 0)
     list(GET matlab_list_of_all_versions 0 _matlab_version_tmp)
   else()
-    set(_matlab_version_tmp "")
+    set(_matlab_version_tmp "unknown")
   endif()
 
   # set the version into the cache
diff --git a/Modules/MatlabTestsRedirect.cmake b/Modules/MatlabTestsRedirect.cmake
index 0ef4c3e..1045be8 100644
--- a/Modules/MatlabTestsRedirect.cmake
+++ b/Modules/MatlabTestsRedirect.cmake
@@ -23,11 +23,12 @@
 #   -DMatlab_PROGRAM=matlab_exe_location
 #   -DMatlab_ADDITIONNAL_STARTUP_OPTIONS=""
 #   -Dtest_name=name_of_the_test
+#   -Dcustom_Matlab_test_command=""
 #   -Dcmd_to_run_before_test=""
 #   -Dunittest_file_to_run
 #   -P FindMatlab_TestsRedirect.cmake
 
-set(Matlab_UNIT_TESTS_CMD -nosplash -nojvm -nodesktop -nodisplay ${Matlab_ADDITIONNAL_STARTUP_OPTIONS})
+set(Matlab_UNIT_TESTS_CMD -nosplash -nodesktop -nodisplay ${Matlab_ADDITIONNAL_STARTUP_OPTIONS})
 if(WIN32)
   set(Matlab_UNIT_TESTS_CMD ${Matlab_UNIT_TESTS_CMD} -wait)
 endif()
@@ -36,6 +37,13 @@ if(NOT test_timeout)
   set(test_timeout 180)
 endif()
 
+# If timeout is -1, then do not put a timeout on the execute_process
+if(test_timeout EQUAL -1)
+  set(test_timeout "")
+else()
+  set(test_timeout TIMEOUT ${test_timeout})
+endif()
+
 if(NOT cmd_to_run_before_test)
   set(cmd_to_run_before_test)
 endif()
@@ -50,16 +58,27 @@ foreach(s IN LISTS additional_paths)
   endif()
 endforeach()
 
-set(unittest_to_run "runtests('${unittest_file_to_run_name}'), exit(max([ans(1,:).Failed]))")
+if(custom_Matlab_test_command)
+  set(unittest_to_run "${custom_Matlab_test_command}")
+else()
+  set(unittest_to_run "runtests('${unittest_file_to_run_name}'), exit(max([ans(1,:).Failed]))")
+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)")
 endif()
 
 set(Matlab_SCRIPT_TO_RUN
-    "addpath(${concat_string}), path, ${cmd_to_run_before_test}, ${unittest_to_run}"
+    "addpath(${concat_string}); ${cmd_to_run_before_test}; ${unittest_to_run}"
    )
 
-set(Matlab_LOG_FILE "${output_directory}/${test_name}.log")
+if(NOT working_directory)
+  set(working_directory "${output_directory}")
+endif()
+
+string(REPLACE "/" "_" clean_test_name "${test_name}")
+set(Matlab_LOG_FILE "${output_directory}/${clean_test_name}.log")
 
 set(devnull)
 if(UNIX)
@@ -69,11 +88,11 @@ elseif(WIN32)
 endif()
 
 execute_process(
-  COMMAND "${Matlab_PROGRAM}" ${Matlab_UNIT_TESTS_CMD} -logfile "${test_name}.log" -r "${Matlab_SCRIPT_TO_RUN}"
+  COMMAND "${Matlab_PROGRAM}" ${Matlab_UNIT_TESTS_CMD} -logfile "${Matlab_LOG_FILE}" -r "${Matlab_SCRIPT_TO_RUN}"
   RESULT_VARIABLE res
-  TIMEOUT ${test_timeout}
+  ${test_timeout}
   OUTPUT_QUIET # we do not want the output twice
-  WORKING_DIRECTORY "${output_directory}"
+  WORKING_DIRECTORY ${working_directory}
   ${devnull}
   )
 
@@ -87,5 +106,5 @@ message("Matlab test ${name_of_the_test} output:\n${matlab_log_content}") # if w
 
 
 if(NOT (res EQUAL 0))
-  message( FATAL_ERROR "[MATLAB] TEST FAILED" )
+  message( FATAL_ERROR "[MATLAB] TEST FAILED Matlab returned ${res}" )
 endif()

-----------------------------------------------------------------------

Summary of changes:
 Modules/FindMatlab.cmake          |   51 ++++++++++++++++++++++++-------------
 Modules/MatlabTestsRedirect.cmake |   35 +++++++++++++++++++------
 2 files changed, 60 insertions(+), 26 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list