From 5923bcb1b94cd5a79dfc57f2ffe6271d999ea67d Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Wed, 25 Nov 2009 21:26:37 -0500 Subject: improve the scripts for building unit tests: * support unsupported/ * use egrep instead of grep, properly escape special chars. --- CMakeLists.txt | 4 ++++ cmake/EigenTesting.cmake | 7 ++++++- scripts/CMakeLists.txt | 3 +++ scripts/buildtests.in | 24 ++++++++++++++++++++++++ scripts/check.in | 4 ++-- signature_of_eigen3_matrix_library | 2 +- test/CMakeLists.txt | 6 ------ test/buildtests.in | 23 ----------------------- unsupported/test/CMakeLists.txt | 5 ----- 9 files changed, 40 insertions(+), 38 deletions(-) create mode 100755 scripts/buildtests.in delete mode 100755 test/buildtests.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 33e7584c4..10c72ab38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,6 +152,9 @@ add_subdirectory(doc EXCLUDE_FROM_ALL) include(CTest) enable_testing() # must be called from the root CMakeLists, see man page +include(EigenTesting) +ei_init_testing() + if(EIGEN_LEAVE_TEST_IN_ALL_TARGET) add_subdirectory(test) # can't do EXCLUDE_FROM_ALL here, breaks CTest else() @@ -164,6 +167,7 @@ add_subdirectory(demos EXCLUDE_FROM_ALL) add_subdirectory(blas EXCLUDE_FROM_ALL) +# must be after test and unsupported, for configuring buildtests.in add_subdirectory(scripts EXCLUDE_FROM_ALL) # TODO: consider also replacing EIGEN_BUILD_BTL by a custom target "make btl"? diff --git a/cmake/EigenTesting.cmake b/cmake/EigenTesting.cmake index 43ae53cc1..ce567abc3 100644 --- a/cmake/EigenTesting.cmake +++ b/cmake/EigenTesting.cmake @@ -107,7 +107,10 @@ endmacro(ei_add_test_internal) # # Again, ctest -R allows to run all matching tests. macro(ei_add_test testname) - set(cmake_tests_list "${cmake_tests_list}${testname}\n") + get_property(EIGEN_TESTS_LIST GLOBAL PROPERTY EIGEN_TESTS_LIST) + set(EIGEN_TESTS_LIST "${EIGEN_TESTS_LIST}${testname}\n") + set_property(GLOBAL PROPERTY EIGEN_TESTS_LIST "${EIGEN_TESTS_LIST}") + file(READ "${testname}.cpp" test_source) set(parts 0) string(REGEX MATCHALL "CALL_SUBTEST_[0-9]+|EIGEN_TEST_PART_[0-9]+" @@ -204,10 +207,12 @@ macro(ei_init_testing) define_property(GLOBAL PROPERTY EIGEN_TESTED_BACKENDS BRIEF_DOCS " " FULL_DOCS " ") define_property(GLOBAL PROPERTY EIGEN_MISSING_BACKENDS BRIEF_DOCS " " FULL_DOCS " ") define_property(GLOBAL PROPERTY EIGEN_TESTING_SUMMARY BRIEF_DOCS " " FULL_DOCS " ") + define_property(GLOBAL PROPERTY EIGEN_TESTS_LIST BRIEF_DOCS " " FULL_DOCS " ") set_property(GLOBAL PROPERTY EIGEN_TESTED_BACKENDS "") set_property(GLOBAL PROPERTY EIGEN_MISSING_BACKENDS "") set_property(GLOBAL PROPERTY EIGEN_TESTING_SUMMARY "") + set_property(GLOBAL PROPERTY EIGEN_TESTS_LIST "") endmacro(ei_init_testing) if(CMAKE_COMPILER_IS_GNUCXX) diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index b75e99d5e..acf3bb6e9 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -1,3 +1,6 @@ +get_property(EIGEN_TESTS_LIST GLOBAL PROPERTY EIGEN_TESTS_LIST) +configure_file(buildtests.in ${CMAKE_BINARY_DIR}/buildtests) + configure_file(check.in ${CMAKE_BINARY_DIR}/check) configure_file(debug.in ${CMAKE_BINARY_DIR}/debug) configure_file(release.in ${CMAKE_BINARY_DIR}/release) diff --git a/scripts/buildtests.in b/scripts/buildtests.in new file mode 100755 index 000000000..1cc8e956f --- /dev/null +++ b/scripts/buildtests.in @@ -0,0 +1,24 @@ +#!/bin/bash + +if [ $# == 0 -o $# -ge 3 ] +then + echo "usage: ./buildtests regexp [jobs]" + echo " makes tests matching the regexp, with [jobs] concurrent make jobs" + exit 0 +fi + +TESTSLIST="${EIGEN_TESTS_LIST}" + +targets_to_make=`echo "$TESTSLIST" | egrep "$1" | sed s/^/test_/g | xargs echo` + +if [ $# == 1 ] +then + make $targets_to_make + exit $? +fi + +if [ $# == 2 ] +then + make -j $2 $targets_to_make + exit $? +fi diff --git a/scripts/check.in b/scripts/check.in index 2a862fd80..ff3c96441 100755 --- a/scripts/check.in +++ b/scripts/check.in @@ -4,9 +4,9 @@ if [ $# == 0 -o $# -ge 3 ] then echo "usage: ./check regexp [jobs]" - echo " makes and runs tests matching the regexp, with concurrent make jobs" + echo " makes and runs tests matching the regexp, with [jobs] concurrent make jobs" exit 0 fi # TODO when ctest 2.8 comes out, honor the jobs parameter -./buildtests $* && ctest -R $1 \ No newline at end of file +./buildtests "$1" "$2" && ctest -R "$1" diff --git a/signature_of_eigen3_matrix_library b/signature_of_eigen3_matrix_library index 477732ef4..80aaf4621 100644 --- a/signature_of_eigen3_matrix_library +++ b/signature_of_eigen3_matrix_library @@ -1 +1 @@ -This file is just there as a signature to help identify directories containing Eigen3. When writing for a script looking for Eigen3, just look for this file. This is especially useful to help disambiguate with Eigen2... +This file is just there as a signature to help identify directories containing Eigen3. When writing a script looking for Eigen3, just look for this file. This is especially useful to help disambiguate with Eigen2... diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c91ec328b..ffe89915a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -3,10 +3,6 @@ add_custom_target(buildtests) add_custom_target(check COMMAND "ctest") add_dependencies(check buildtests) - -include(EigenTesting) -ei_init_testing() - option(EIGEN_SPLIT_LARGE_TESTS "Split large tests into smaller executables" ON) find_package(GSL) @@ -169,5 +165,3 @@ if(CMAKE_COMPILER_IS_GNUCXX) endif(CMAKE_COMPILER_IS_GNUCXX) ei_add_property(EIGEN_TESTING_SUMMARY "CXX_FLAGS: ${CMAKE_CXX_FLAGS}\n") ei_add_property(EIGEN_TESTING_SUMMARY "Sparse lib flags: ${SPARSE_LIBS}\n") - -configure_file(buildtests.in ${CMAKE_BINARY_DIR}/buildtests) diff --git a/test/buildtests.in b/test/buildtests.in deleted file mode 100755 index c24234930..000000000 --- a/test/buildtests.in +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -if [ $# == 0 -o $# -ge 3 ] -then - echo "usage: ./buildtests regexp [jobs]" - echo " makes tests matching the regexp, with concurrent make jobs" - exit 0 -fi - -TESTSLIST="${cmake_tests_list}" -targets_to_make=`echo "$TESTSLIST" | grep "$1" | sed s/^/test_/g | xargs echo` - -if [ $# == 1 ] -then - make $targets_to_make - exit $? -fi - -if [ $# == 2 ] -then - make -j $2 $targets_to_make - exit $? -fi diff --git a/unsupported/test/CMakeLists.txt b/unsupported/test/CMakeLists.txt index 057c2026e..58af79351 100644 --- a/unsupported/test/CMakeLists.txt +++ b/unsupported/test/CMakeLists.txt @@ -1,8 +1,3 @@ - -include(EigenTesting) - -enable_testing() - find_package(Adolc) include_directories(../../test) -- cgit v1.2.3