Skip to content

Commit

Permalink
update most tests to work without installing
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk-thomas committed Jun 19, 2015
1 parent e309775 commit 7283291
Showing 4 changed files with 21 additions and 5 deletions.
10 changes: 9 additions & 1 deletion cmake/GazeboTestUtils.cmake
Original file line number Diff line number Diff line change
@@ -44,7 +44,15 @@ macro (gz_build_tests)
add_test(${BINARY_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}
--gtest_output=xml:${CMAKE_BINARY_DIR}/test_results/${BINARY_NAME}.xml)

set_tests_properties(${BINARY_NAME} PROPERTIES TIMEOUT 240)
set(_env_vars)
list(APPEND _env_vars "CMAKE_PREFIX_PATH=${CMAKE_BINARY_DIR}:${CMAKE_PREFIX_PATH}")
list(APPEND _env_vars "GAZEBO_PLUGIN_PATH=${CMAKE_BINARY_DIR}/plugins:${CMAKE_BINARY_DIR}/plugins/events:${CMAKE_BINARY_DIR}/plugins/rest_web")
list(APPEND _env_vars "GAZEBO_RESOURCE_PATH=${CMAKE_SOURCE_DIR}")
list(APPEND _env_vars "PATH=${CMAKE_BINARY_DIR}/gazebo:${CMAKE_BINARY_DIR}/tools:$ENV{PATH}")
list(APPEND _env_vars "PKG_CONFIG_PATH=${CMAKE_BINARY_DIR}/cmake/pkgconfig:$PKG_CONFIG_PATH")
set_tests_properties(${BINARY_NAME} PROPERTIES
TIMEOUT 240
ENVIRONMENT "${_env_vars}")

# Check that the test produced a result and create a failure if it didn't.
# Guards against crashed and timed out tests.
2 changes: 1 addition & 1 deletion test/pkgconfig/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
set (tests config-pkgconfig.cc)
add_definitions("-DSOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/plugin\"")
add_definitions(-DSOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/plugin\" -DGAZEBO_EXPECTED_VERSION="${GAZEBO_VERSION_FULL}")
gz_build_tests(${tests})
11 changes: 8 additions & 3 deletions test/pkgconfig/config-pkgconfig.cc
Original file line number Diff line number Diff line change
@@ -22,15 +22,20 @@ TEST(PkgConfig, Config)
{
char cmd[1024];

// Delete previous build directory to not reuse previous CMakeCache
snprintf(cmd, sizeof(cmd), "rm -fr %s/test/pkgconfig/plugin",
PROJECT_BINARY_PATH);
ASSERT_EQ(system(cmd), 0);

// Create a build directory in the project binary directory so that we
// don't pollute the source tree
snprintf(cmd, sizeof(cmd), "mkdir %s/test/pkgconfig/plugin",
PROJECT_BINARY_PATH);
ASSERT_GT(system(cmd), -1);
ASSERT_EQ(system(cmd), 0);

// Run cmake
snprintf(cmd, sizeof(cmd), "cd %s/test/pkgconfig/plugin; cmake %s",
PROJECT_BINARY_PATH, SOURCE_DIR);
snprintf(cmd, sizeof(cmd), "cd %s/test/pkgconfig/plugin; cmake %s -DGAZEBO_EXPECTED_VERSION=%s",
PROJECT_BINARY_PATH, SOURCE_DIR, GAZEBO_EXPECTED_VERSION);
ASSERT_EQ(system(cmd), 0);

// Make
3 changes: 3 additions & 0 deletions test/pkgconfig/plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -10,6 +10,9 @@ if (PKG_CONFIG_FOUND)
pkg_check_modules(GAZEBO gazebo)
string (REPLACE ";" " " GAZEBO_CFLAGS "${GAZEBO_CFLAGS}")
endif()
if (NOT "${GAZEBO_VERSION}" STREQUAL "${GAZEBO_EXPECTED_VERSION}")
message(FATAL_ERROR "Expected version is '${GAZEBO_EXPECTED_VERSION}' but found '${GAZEBO_VERSION}' in '${GAZEBO_PREFIX}'")
endif()
include_directories(${GAZEBO_INCLUDE_DIRS} ${IGNITION-MATH_INCLUDE_DIRS})
link_directories(${GAZEBO_LIBRARY_DIRS} ${IGNITION-MATH_LIBRARY_DIRS})

0 comments on commit 7283291

Please sign in to comment.