From 4fa02a0e81a33416af7e73a4708625ea7d2f347a Mon Sep 17 00:00:00 2001 From: Michel Zou Date: Thu, 14 Apr 2016 22:04:49 +0200 Subject: [PATCH] Run mlapack_test through ctest The 'test' target is reserved to ctest and we avoid this cmake warning: CMake Warning (dev) at src/mlpack/CMakeLists.txt:87 (add_custom_target): Policy CMP0037 is not set: Target names should not be reserved and should match a validity pattern. Run "cmake --help-policy CMP0037" for policy details. Use the cmake_policy command to set the policy and suppress this warning. The target name "test" is reserved or not valid for certain CMake features, such as generator expressions, and may result in undefined behavior. This warning is for project developers. Use -Wno-dev to suppress it. Using ctest over a custom target has also the advantage of allowing to use an interpreter when cross-compiling. Now this looks like this: $ make test Running tests... Test project /home/xantares/projects/mlpack/build Start 1: mlpack_test 1/1 Test #1: mlpack_test ...................... Passed 529.50 sec 100% tests passed, 0 tests failed out of 1 Total Test time (real) = 529.53 sec Ctest can also be used directly with a timeout: ```ctest --output-on-failure --timeout 1800``` instead of ```travis_wait 30 ./bin/mlpack_test -p``` --- CMakeLists.txt | 2 ++ src/mlpack/CMakeLists.txt | 7 ------- src/mlpack/tests/CMakeLists.txt | 6 ++++++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d018fb9f38..b5bf072319 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,8 @@ option(ARMA_EXTRA_DEBUG "Compile with extra Armadillo debugging symbols." OFF) option(MATLAB_BINDINGS "Compile MATLAB bindings if MATLAB is found." OFF) option(TEST_VERBOSE "Run test cases with verbose output." OFF) +enable_testing () + # Include modules in the CMake directory. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMake") diff --git a/src/mlpack/CMakeLists.txt b/src/mlpack/CMakeLists.txt index df77a6d733..28e56ec994 100644 --- a/src/mlpack/CMakeLists.txt +++ b/src/mlpack/CMakeLists.txt @@ -82,10 +82,3 @@ install(TARGETS mlpack ARCHIVE DESTINATION lib) add_dependencies(mlpack mlpack_headers) - -# For 'make test'. -add_custom_target(test - ${CMAKE_BINARY_DIR}/bin/mlpack_test "--log_level=test_suite" # Set UTF runtime param - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/ # This is where test files are put. - COMMENT "Running mlpack test" - DEPENDS mlpack_test) diff --git a/src/mlpack/tests/CMakeLists.txt b/src/mlpack/tests/CMakeLists.txt index 4a33625ad6..e5b08b4bb4 100644 --- a/src/mlpack/tests/CMakeLists.txt +++ b/src/mlpack/tests/CMakeLists.txt @@ -94,3 +94,9 @@ add_custom_command(TARGET mlpack_test COMMAND ${CMAKE_COMMAND} -E tar xjpf mnist_first250_training_4s_and_9s.tar.bz2 WORKING_DIRECTORY ${PROJECT_BINARY_DIR} ) + +# For 'make test'. +add_test (NAME mlpack_test + COMMAND mlpack_test "--log_level=test_suite" # Set UTF runtime param + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/ # This is where test files are put. +) \ No newline at end of file