Skip to content

Commit

Permalink
improve the scripts for building unit tests:
Browse files Browse the repository at this point in the history
* support unsupported/
* use egrep instead of grep, properly escape special chars.
  • Loading branch information
bjacob committed Nov 26, 2009
1 parent eb7b4b0 commit 13d2304
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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"?
Expand Down
7 changes: 6 additions & 1 deletion cmake/EigenTesting.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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]+"
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 4 additions & 3 deletions test/buildtests.in → scripts/buildtests.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
if [ $# == 0 -o $# -ge 3 ]
then
echo "usage: ./buildtests regexp [jobs]"
echo " makes tests matching the regexp, with <jobs> concurrent make jobs"
echo " makes tests matching the regexp, with [jobs] concurrent make jobs"
exit 0
fi

TESTSLIST="${cmake_tests_list}"
targets_to_make=`echo "$TESTSLIST" | grep "$1" | sed s/^/test_/g | xargs echo`
TESTSLIST="${EIGEN_TESTS_LIST}"

targets_to_make=`echo "$TESTSLIST" | egrep "$1" | sed s/^/test_/g | xargs echo`

if [ $# == 1 ]
then
Expand Down
4 changes: 2 additions & 2 deletions scripts/check.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
if [ $# == 0 -o $# -ge 3 ]
then
echo "usage: ./check regexp [jobs]"
echo " makes and runs tests matching the regexp, with <jobs> 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
./buildtests "$1" "$2" && ctest -R "$1"
2 changes: 1 addition & 1 deletion signature_of_eigen3_matrix_library
Original file line number Diff line number Diff line change
@@ -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...
6 changes: 0 additions & 6 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
5 changes: 0 additions & 5 deletions unsupported/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@

include(EigenTesting)

enable_testing()

find_package(Adolc)

include_directories(../../test)
Expand Down

0 comments on commit 13d2304

Please sign in to comment.