From 8023d54f814b6bfd706ad90a8fe4ad231551d35b Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Fri, 9 Nov 2012 05:34:47 +0000 Subject: [PATCH] improved invocation of rosunit binary and scripts --- core/rosbuild/private.cmake | 10 +++++----- core/rosbuild/public.cmake | 10 +++++----- tools/rosunit/cmake/rosunit-extras.cmake.em | 16 ++++++++++++---- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/core/rosbuild/private.cmake b/core/rosbuild/private.cmake index 8cf19bf6..ffb3fc1f 100644 --- a/core/rosbuild/private.cmake +++ b/core/rosbuild/private.cmake @@ -105,7 +105,7 @@ endmacro(_rosbuild_check_package_location) # helper function to register check that results were generated (#580) macro(_rosbuild_check_rostest_xml_result test_name test_file) add_custom_target(${test_name}_result - COMMAND ${rosunit_path}/scripts/check_test_ran.py ${test_file} + COMMAND ${ROSUNIT_SCRIPTS_DIR}/check_test_ran.py ${test_file} VERBATIM) # Redeclaration of target is to workaround bug in 2.4.6 if(CMAKE_MINOR_VERSION LESS 6) @@ -134,13 +134,13 @@ macro(_rosbuild_add_gtest exe) # But don't depend on the gtest executable if rosbuild_test_nobuild is set, #3008 if(NOT rosbuild_test_nobuild) add_custom_target(test_${_testname} - COMMAND ${rosunit_path}/../..//bin/rosunit --name=${_testname} --time-limit=${_gtest_TIMEOUT} ${EXECUTABLE_OUTPUT_PATH}/${exe} + COMMAND ${ROSUNIT_EXE} --name=${_testname} --time-limit=${_gtest_TIMEOUT} ${EXECUTABLE_OUTPUT_PATH}/${exe} DEPENDS ${EXECUTABLE_OUTPUT_PATH}/${exe} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} VERBATIM) else(NOT rosbuild_test_nobuild) add_custom_target(test_${_testname} - COMMAND ${rosunit_path}/../..//bin/rosunit --name=${_testname} --time-limit=${_gtest_TIMEOUT} ${EXECUTABLE_OUTPUT_PATH}/${exe} + COMMAND ${ROSUNIT_EXE} --name=${_testname} --time-limit=${_gtest_TIMEOUT} ${EXECUTABLE_OUTPUT_PATH}/${exe} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} VERBATIM) endif(NOT rosbuild_test_nobuild) @@ -167,7 +167,7 @@ endmacro(_rosbuild_add_gtest) # arguments as cmake doesn't know the name of the output file macro(_rosbuild_check_rostest_result test_name test_pkg test_file) add_custom_target(${test_name}_result - COMMAND ${rosunit_path}/scripts/check_test_ran.py --rostest ${test_pkg} ${test_file} + COMMAND ${ROSUNIT_SCRIPTS_DIR}/check_test_ran.py --rostest ${test_pkg} ${test_file} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} VERBATIM) # Redeclaration of target is to workaround bug in 2.4.6 @@ -240,7 +240,7 @@ macro(_rosbuild_add_pyunit file) # Create target for this test # We use rostest to call the executable to get process control, #1629 add_custom_target(pyunit_${_testname} - COMMAND ${rosunit_path}/../..//bin/rosunit --name=${_testname} --time-limit=${_pyunit_TIMEOUT} -- ${file} ${_covarg} + COMMAND ${ROSUNIT_EXE} --name=${_testname} --time-limit=${_pyunit_TIMEOUT} -- ${file} ${_covarg} DEPENDS ${file} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} VERBATIM) diff --git a/core/rosbuild/public.cmake b/core/rosbuild/public.cmake index 050b9c2b..d4062b41 100644 --- a/core/rosbuild/public.cmake +++ b/core/rosbuild/public.cmake @@ -291,11 +291,11 @@ macro(rosbuild_init) # friends add targets and dependencies from these targets. # - # Find rosunit; rosunit_path will be used later - rosbuild_invoke_rospack("" rosunit path find rosunit) + # find rosunit since ROSUNIT_SCRIPTS_DIR and ROSUNIT_EXE will be used later + find_package(rosunit REQUIRED) # Record where we're going to put test results (#2003) - execute_process(COMMAND ${rosunit_path}/scripts/test_results_dir.py + execute_process(COMMAND ${ROSUNIT_SCRIPTS_DIR}/test_results_dir.py OUTPUT_VARIABLE rosbuild_test_results_dir RESULT_VARIABLE _test_results_dir_failed OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -331,13 +331,13 @@ macro(rosbuild_init) add_custom_target(test-results-run) add_custom_target(test-results - COMMAND ${rosunit_path}/scripts/summarize_results.py --nodeps ${_project}) + COMMAND ${ROSUNIT_SCRIPTS_DIR}/summarize_results.py --nodeps ${_project}) add_dependencies(test-results test-results-run) # Do we want coverage reporting (only matters for Python, because # Bullseye already collects everything into a single file). if("$ENV{ROS_TEST_COVERAGE}" STREQUAL "1") add_custom_target(test-results-coverage - COMMAND ${rosunit_path}/scripts/pycoverage_to_html.py + COMMAND ${ROSUNIT_SCRIPTS_DIR}/pycoverage_to_html.py WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) # Make tests run before collecting coverage results add_dependencies(test-results-coverage test-results-run) diff --git a/tools/rosunit/cmake/rosunit-extras.cmake.em b/tools/rosunit/cmake/rosunit-extras.cmake.em index 94d97ac5..c3cf4890 100644 --- a/tools/rosunit/cmake/rosunit-extras.cmake.em +++ b/tools/rosunit/cmake/rosunit-extras.cmake.em @@ -2,15 +2,23 @@ include(CMakeParseArguments) macro(rosunit_initialize_tests) @[if DEVELSPACE]@ - # find program in develspace - find_program_required(ROSUNIT_EXE rosunit + # find binary and scripts in develspace + find_program(ROSUNIT_EXE rosunit PATHS @(PROJECT_SOURCE_DIR)/scripts NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + if(NOT ROSUNIT_EXE) + message(FATAL_ERROR "'rosunit' not found") + endif() + set(ROSUNIT_SCRIPTS_DIR @(PROJECT_SOURCE_DIR)/scripts) @[else]@ - # find program in installspace - find_program_required(ROSUNIT_EXE rosunit + # find binary and scripts in installspace + find_program(ROSUNIT_EXE rosunit PATHS @(CMAKE_INSTALL_PREFIX)/bin NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + if(NOT ROSUNIT_EXE) + message(FATAL_ERROR "'rosunit' not found") + endif() + set(ROSUNIT_SCRIPTS_DIR @(CMAKE_INSTALL_PREFIX)/scripts) @[end if]@ endmacro()